Skip to content

[Bug]: A resumed sub-agent task loses the parent's prompt_cache_key #6655

Open

Description

@enyst

I'm an AI agent (Claude Code) helping Engel Nyst (@enyst) with project maintenance.

The verify-sdk feature map (#5750) found this bug while driving the SDK through its public API. The map records it as a known failure, and the command under Steps to Reproduce shows it on main.

Is there an existing issue for the same bug?

  • I have searched existing issues and this is not a duplicate.

Bug Description

Sub-agent LLM calls carry the parent conversation's id as prompt_cache_key, so delegated work shares the parent's cache shard. That holds when a task is created, but TaskManager._resume_task builds the LocalConversation without prompt_cache_key=... (unlike _get_conversation), so the call after task(resume=...) carries the sub-conversation's own id.

Expected Behavior

Every sub-agent call carries the parent's id, on create and on resume (sub_cache_key_is_parent is [true, true, true]).

Actual Behavior

[true, true, false].

Steps to Reproduce

From a checkout of main (uv sync), with the verify-sdk tools on the path:

export PATH="$PWD/.agents/skills/verify-sdk/scripts:$PATH"
sdk-map run --file S11 --only S11.task-observability

That runs this recipe from the map (each control-sdk call runs a short program in its own HOME, persistence and workspace):

export SDK_VERIFY_RUN=$(control-sdk new --field run)
control-sdk program S11/task_lifecycle \
  --check sub_cache_key_is_parent.0 eq true --check sub_cache_key_is_parent.1 eq true \
  --check sub_cache_key_is_parent.2 eq true --check sub_session_differs eq true

Acceptance Criteria

  • A resumed task's calls carry the parent's prompt_cache_key.
  • A test covers resume.
  • The S11.task-observability bullet in .agents/skills/verify-sdk/references/feature-map/ passes and its known-failure note is removed.

Installation Method

uv sync in a checkout of main


OpenHands AI triage

The following comments and acceptance criteria were added by the OpenHands AI agent.

Triage

Verified on main: TaskManager._get_conversation (task creation) builds the sub-conversation with prompt_cache_key=str(parent.state.id), but TaskManager._resume_task builds the LocalConversation without it, so LocalConversation falls back to its own conversation id and a resumed task starts a new prompt-cache shard. The repository's verify-sdk feature map records the same failure under S11.task-observability (reproduced 2026-10-13). Scope: make _resume_task construct the sub-conversation the same way the create path does, per the repository lifecycle rule that resumed conversations preserve the same observable configuration and behavior as newly created ones. All resume paths funnel through _resume_task, so one construction fix covers them.

Non-goals: no change to the task-creation path or to LocalConversation's default own-id prompt_cache_key for non-delegate conversations; no change to delegate trace metadata or tagging (the Laminar-backed observability item remains blocked and separate); no agent-server, remote-conversation, or TypeScript client changes; no new public API surface.

Acceptance Criteria

  • After task(resume="task_..."), the resumed task's sub-conversation LLM call context carries prompt_cache_key equal to the parent conversation's id (the S11.task-lifecycle scenario reports sub_cache_key_is_parent as true for the resume call, i.e. [true, true, true]).
  • A regression test in tests/tools/task/test_task_manager.py asserts that a resumed task's LocalConversation.get_llm_call_context().prompt_cache_key equals str(parent.state.id), as the resume-path counterpart of test_sub_agents_inherit_parent_prompt_cache_key.
  • The S11.task-observability recipe passes (sdk-map run --file S11 --only S11.task-observability) and the known-failure note about the resume call carrying the sub-conversation's own id is removed from .agents/skills/verify-sdk/references/feature-map/S11-subagents-delegation.md.
  • Task creation is unchanged: a newly created task's calls still carry the parent's prompt_cache_key (existing test_sub_agents_inherit_parent_prompt_cache_key keeps passing).

Activity

  1. added
    bug
    ready-for-dev
    on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugready-for-dev

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions