fix(connectors): persist connector_runtime_turn_id so cache eviction can't lose it - #2
Open
yiboyasss wants to merge 3 commits into
Conversation
Persists the turn id that owns a run's ephemeral connector secrets on the Task row itself. Previously this id lived only in the cached AgentService's tool_config, which a resume rebuild after cache eviction never re-supplied. Nullable, no index (read alongside the row it belongs to, never queried by value); historical rows read back as NULL.
…im time Written in the same UPDATE that mints run_id, so the two can never disagree about which run a turn belongs to. An APPEND claim's own new turn_id (a fresh interaction lifetime) overwrites the prior, now-finished turn's value rather than leaving the row pointing at it.
Every resume path (websocket resume, v1 reply, A2A, the channel bots) rebuilds or resyncs a task's agent with no live turn_id of its own to pass. Without a fallback, the rebuilt tool_config looked up ephemeral connector secrets under None even when a still-live turn's secrets were sitting in connector_runtime.py's process-local store, reachable only by the id the original CREATE/APPEND claim persisted on the row. An explicit turn_id from the normal execution path is never overridden.
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.
Summary
Stacked on xorbitsai#2110 (PR 1: ephemeral connector secret TTL/renewal). This slice is the identity-persistence half of the same secret-lifecycle work: do not merge into
mainyet — this targets xorbitsai#2110's branch and will be retargeted toxorbitsai/xagent:mainonce xorbitsai#2110 merges, so the diff shown here only covers this PR's own change, not xorbitsai#2110's.The turn id that owns a run's ephemeral connector secrets previously lived only in the cached
AgentService'stool_config. A resume rebuild after a cache eviction (idle reclamation, capacity eviction, a scope-fingerprint mismatch) never re-supplied it — every resume path (websocket explicit/message-triggered resume, v1 reply, A2A, the channel bots) omitsconnector_runtime_turn_idwhen callingget_agent_for_task. The rebuilt tool_config then looked up ephemeral secrets underNone, even though a still-live turn's secrets were sitting inconnector_runtime.py's process-local store, addressable only by the id the original CREATE/APPEND claim minted.tasks.connector_runtime_turn_idcolumn (migration20260904_add_connector_runtime_turn_id_to_tasks), no index — read alongside the row it belongs to, never queried by value.run_id(task_orchestrator._claim_turn_no_commit), so the two can never disagree about which run a turn belongs to. An APPEND claim's own new turn_id overwrites the prior, now-finished turn's value.get_agent_for_taskfalls back to the persisted value when a caller passes none, without overriding an explicit one from the normal execution path (which always knows its own live turn_id).Test plan
taskstable, historical rows read back asNULL(tests/alembic/), plus the full sqlite migration-chain integration suitetests/web/api/v1/test_tasks.py)Noneonto the tool config (tests/web/api/test_get_agent_for_task_connector_runtime_turn_id_fallback.py)tests/web/api, orchestrator/snapshot/connector-runtime tests) green; only pre-existing, unrelated flakesalembic-checkverified directly (single head, correctdown_revision) since the pre-commit hook's ownuv-provisioned venv couldn't buildonnxruntimefor this machine's Python