fix(ai): ai-spawned sub-runners persist their own runner doc, linked by session_id#1277
Merged
Merged
Conversation
…eir own runner doc _get_result_context now strips the parent's runner-identity keys (task_id/workflow_id/scan_id/task_chunk_id) from the child context and marks it has_parent=True, while still keeping session_id/drivers/ workspace_id/workspace_name. Previously a child inheriting the parent's task_id would make update_runner target the PARENT's doc instead of minting its own, clobbering the parent runner. The child is now linked to the conversation only via session_id.
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
What / why (PR 2 of the runner-parenting design — core foundation)
AI-task-spawned sub-runners (nmap, httpx, subagents, …) run and their findings persist, but the sub-runner itself never created its own runner doc — so it never appeared in runner history. Root cause: the child inherited the parent ai task's
context.task_id, soupdate_runner/runner_idtargeted the parent's doc instead of minting a new one.Fix
_get_result_contextnow builds a clean child context: strips the parent's runner-identity keys (task_id/workflow_id/scan_id/task_chunk_id), keepssession_id/drivers/workspace_*. Each child now takesupdate_runner's insert branch → mints its own doc, linked to the conversation bycontext.session_id.Verified (empirical)
Probe (
secator x ai -p "Run nmap … on scanme.nmap.org" --dangerous -driver mongodb -ws …):nmapchild persists with its own_id(≠ parent),context.task_id= its own,context.session_id= the conversation,status=SUCCESS.Tests
TestChildContextParenting(child context keeps session/drivers/workspace, setshas_parent, strips the four identity keys).test_ai_actions.py85/85; no new failures vs branch baseline.Not in this PR (design's later phases, go through the user)
GET /ai/conversations/{session_id}/runnerslist resolver (unions tasks/workflows/scans bycontext.session_id).has_parent(controls whether they show as top-level in the general runner history vs nested). The persistedhas_parentis currentlyfalse; parenting-by-session_idworks regardless.Part of the AI-task reliability series →
ai-resiliency(#1241).🤖 Generated with Claude Code