th-137b91: Python server durable-executor selection seam (Q parity) - #452
Merged
Conversation
Route each TurnRunner turn through an AgentExecutor instead of calling SmoothAgent.run_stream directly, so a durable backend (ADR-030) can be selected in one place — the Python analog of the Rust server's turn_executor (runner.rs). - select_turn_executor(injected, env_value): default in-process; a durable backend is dependency-INJECTED (TurnRunner(executor=...)) so the seam needs no hard dependency on the Temporal package. Selection is env-gated on SMOOTH_AGENT_DURABLE_EXECUTOR — the injected backend is used only when the env opts in (differs deliberately from Rust, where injection wins unconditionally: here the env is the explicit opt-in so an injected backend can never silently take over a deployment that didn't ask). Asking for durable mode with nothing injected warns and falls back to in-process. - durable_requested(value): 1/true/on/yes parse, split out for testability. - The turn's stream now flows through self._executor.execute_streaming(agent, ...). Default (nothing injected) = InProcessExecutor, a verbatim delegation to run_stream — behavior unchanged. Tests: durable_requested parse table, select_turn_executor (injected-when-on, ignored-when-off, warn-fallback, fresh-per-call), and two real turns driven through a fake injected executor (env on -> durable used; off -> in-process). Full server suite: 350 passed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YbN45JeWDbcjvFqGJvmVD3
🦋 Changeset detectedLatest commit: 8873083 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…tor) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YbN45JeWDbcjvFqGJvmVD3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Polyglot-parity item Q (ADR-030 durable execution) for the Python server.
TurnRunnercalledSmoothAgent.run_streamdirectly, so there was no single placea durable backend could be selected — unlike the Rust server, whose
turn_executor(
runner.rs) picks the executor a turn runs on.Solution
Route each turn through the engine's
AgentExecutorseam, selected once inselect_turn_executor— the Python analog of the Rustturn_executor.TurnRunner(executor=...)as an opaque
AgentExecutor, so the server keeps no hard dependency on theTemporal package. (The durable backend itself is the Python
smooai-smooth-operator-temporalpackage, item I.)SMOOTH_AGENT_DURABLE_EXECUTOR(1/true/on/yes) opts in. Theinjected backend is used only when the env asks; otherwise — and whenever nothing
is injected — the turn runs on
InProcessExecutor, a verbatim delegation torun_stream(behavior unchanged). Asking for durable mode with nothing injectedwarns and falls back rather than silently pretending a turn is durable.
durable_requested(value)is split out so the parse is testable without mutatingprocess-global state.
Verification
test_durable_executor_seam.py:durable_requestedparse table;select_turn_executor(injected-when-on, ignored-when-off, warn-fallback,fresh-per-call); and two real turns driven through a fake injected executor
(env on → durable used; off → in-process). 19 passed.
run_stream→execute_streamingswapregresses nothing.
ruff check+ruff format --checkclean.🤖 Generated with Claude Code
https://claude.ai/code/session_01YbN45JeWDbcjvFqGJvmVD3