[Bug]: TaskManager loses sub-agent task index across parent conversation resume and mismatches subagent_type
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- python
- Domain
- ai-infra-agents, backend
Research direction
Start with TaskManager._ensure_parent(), TaskManager.close(), and the task resume path; the issue identifies these as the points where the in-memory registry is lost and the original subagent_type is missing. Read the task tests under tests/tools/task/ and run uv run pytest tests/tools/task/ to see the regression coverage. Done means a resumed parent reloads the task index, resumes with the recorded type, and the regression tests pass; linked PR #6986 is already open.
Written by the indexing model from the issue text.
Description
Is there an existing issue for the same bug?
- I have searched existing issues and this is not a duplicate. (Related to #5074 which covers server-crash mid-run; this covers clean multi-turn parent conversation resume.)
Bug Description
TaskManager._ensure_parent() persists sub-agent LocalConversation directories under <parent_persistence_dir>/subagents/<subagent_id>/, and TaskManager.close() intentionally preserves that directory when the parent persists. However:
self._tasks(task_00000001 -> Task(conversation_id=...)) is stored only in memory and never reloaded from<parent_persistence_dir>/subagents/, causingtask(resume="task_00000001")in a resumed parent session to fail withValueError: Task 'task_00000001' not found. Available tasks:.Taskdoes not record thesubagent_typeit was created with; if the model omits or changessubagent_typeonresume,Agent._verify_persistedraisesCannot resume conversation: tools were removed mid-conversation.
Expected Behavior
Resuming a persisted parent conversation in a new process and calling task(resume="task_00000001", prompt=...) should reload the persisted task registry and restore the sub-agent using its original subagent_type.
Actual Behavior
Reproducible via uv run pytest:
- Create a
LocalConversationwithpersistence_dirand runTaskManager.start_task(..., subagent_type="code-explorer")(task_00000001), then callmanager.close(). - Create a new
TaskManagerattached to the resumed parent conversation and callstart_task(resume="task_00000001", prompt="follow up"). ValueError: Task 'task_00000001' not found. Available tasks:is raised despite the sub-agent conversation existing on disk undersubagents/.
Discovered via TraceTrial-Bench (arXiv:2610.32285, mechanism node C6). Companion fix ready in #6986.
Acceptance Criteria
-
TaskManagerpersiststasks_index.jsonunder<parent_persistence_dir>/subagents/and reloads it when attaching to a persisted parent conversation - Resuming a task reuses the
subagent_typerecorded at creation time soAgent._verify_persistedsucceeds - Automated regression tests pass via
uv run pytest tests/tools/task/
OpenHands AI triage
The following comments and acceptance criteria were added by the OpenHands AI agent.
Triage
Verified against main: TaskManager._tasks is memory-only (never reloaded in _ensure_parent(), cleared in close()), Task carries no subagent_type, and AgentBase._verify_persisted raises "Cannot resume conversation: tools were removed mid-conversation" when a resumed agent lacks tools the persisted conversation had. Both reported failures follow from this, so the issue is reproducible and its expected behavior is unambiguous.
Scope: persist a task index under <parent_persistence_dir>/subagents/ (e.g. tasks_index.json), reload it when attaching to a persisted parent, and restore each task's creation-time subagent_type on resume. Existing lifecycle rules are kept: sub-agent data is preserved when the parent persists, and the temporary subagents directory is removed on close when it does not.
Non-goals: no change to the persisted sub-agent conversation directory layout; no change to the task tool's LLM-facing action/observation schema or prompt; no handling of the server-crash mid-run scenario tracked in #5074.
Priority: medium — external user report with a reproduced failure in the actual product workflow (the companion PR #6986 records a live end-to-end reproduction: session-2 resume of a persisted parent fails on main and succeeds with the fix, with a real LLM and no mocks). Not high: the parent conversation keeps working and can start new tasks; only cross-session resume of a prior sub-agent task fails, and starting a new task is a workaround.
Acceptance Criteria
- With a parent
LocalConversationthat has apersistence_dir, after the parent is closed and re-attached in a new session, a freshTaskManagercallingstart_task(resume="<earlier task id>", prompt=...)succeeds instead of raisingValueError: Task '<id>' not found, and the sub-agent continues in its original persisted conversation (same conversation ID). - A task created with
subagent_typeX is resumed using X — the type recorded at creation — even when the resume call omitssubagent_typeor passes a different value, so the persisted sub-agent conversation resumes without raising "Cannot resume conversation: tools were removed mid-conversation". - After reloading the persisted index, creating a new task allocates the next unused task ID (e.g.
task_00000002aftertask_00000001) rather than reusing an existing ID. - Attaching a
TaskManagerto a persisted parent whosesubagents/directory has no task index (e.g. a parent persisted before this change) does not raise, and resuming an unregistered task ID still raisesValueError: Task '<id>' not found. Available tasks: .... - With a non-persisted parent,
TaskManager.close()still removes its temporarysubagents/directory; with a persisted parent,close()does not delete<parent_persistence_dir>/subagents/. - Automated regression tests under
tests/tools/task/cover the cross-session index reload andsubagent_typerestoration, anduv run pytest tests/tools/task/passes.
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 797
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 354
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OpenHands/software-agent-sdk
-
[Bug]: `list_directory` reports a complete listing as truncated when a directory has exactly 500 entriesPossibly taken @balabommablock-cpu claimed this 29 days ago. Openbug priority:low ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
OpenHands/software-agent-sdk#6133 ·
Maintainers usually reply within 1 day
-
[Bug]: Command hook that exits 1 is treated as blocking when its stdout is a JSON `deny` or `continue: false`Possibly taken A pull request linked to this issue is open or already merged. Openbug priority:low ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OpenHands/software-agent-sdk#6116 · 3 comments ·
Maintainers usually reply within 1 day
-
[Bug]: TypeScript GET-with-body requests remain pending after a truncated responsePossibly taken @BlueRaddish claimed this 34 days ago. Openbug priority:low ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
OpenHands/software-agent-sdk#6059 ·
Maintainers usually reply within 1 day
-
[Bug]: Document whether `prompt_tokens` includes `cache_read_tokens` in accumulated token usagePossibly taken @Jaxon1216 claimed this 36 days ago. Openpriority:low ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
OpenHands/software-agent-sdk#5975 ·
Maintainers usually reply within 1 day
-
priority:low
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
OpenHands/software-agent-sdk#5708 · 1 comment ·
Maintainers usually reply within 1 day
All issues in OpenHands/software-agent-sdk
Similar issues
-
[Bug]: reme CLI crashes when the running server used a relative config pathPossibly taken @nurlanmnn claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
agentscope-ai/ReMe#770 ·
Maintainers usually reply within 1 day
-
Pi: paused model calls are reported as "not signed in" when the model's provider comes from an extensionPossibly taken @balcsida claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
microsoft/TokenEconomizer#288 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 67/100
sickn33/agentic-awesome-skills#2437 ·
Maintainers usually reply within 1 day
-
site-bug triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ethereum/consensus-specs#5846 ·
Maintainers usually reply within 1 day