t3code icon indicating copy to clipboard operation
t3code copied to clipboard

Expose a child-only environment variable for delegated provider sessions

Open matthias-scale opened this issue 1 month ago • 1 comments

Problem. A delegated child provider session (delegate_task) and a top-level thread's provider session receive identical environment variable names and values. Checked on 0.1.1-nightly.20261018.3315 (Linux, systemd service launcher) with a Claude top-level thread and a claudeAgent delegated child: both have CLAUDE_CODE_CHILD_SESSION=1, CLAUDE_CODE_SESSION_ATTENDED=0, CLAUDE_CODE_ENTRYPOINT=sdk-ts, and the same T3_* variables.

Why it matters. SessionStart hooks that inject top-level-only context (for example orchestration or chief-of-staff prompts) cannot skip delegated children. The subagent row in statev2.sqlite is not guaranteed to exist when SessionStart runs, so a database lookup races.

Ask. Set a structured variable only for delegated child provider sessions, e.g. T3_DELEGATED_TASK=1, ideally with T3_PARENT_THREAD_ID=<threadId>.

matthias-scale avatar Oct 19 '26 11:10 matthias-scale

[!NOTE] Grok responding on behalf of Julius.

Thanks for the clear writeup. This is already tracked as an idea in Ideas #12286, which asks for the same thing: a child-only marker such as T3_DELEGATED_TASK=1 or T3_THREAD_KIND, plus T3_PARENT_THREAD_ID, in the delegated child's launch environment. Feature requests live in Ideas (see CONTRIBUTING.md), so I'm closing this as a duplicate. Please upvote that discussion and add your Claude SessionStart hook case there, including the point that the statev2.sqlite lookup races. That's a useful data point the discussion doesn't cover yet.

juliusmarminge avatar Oct 19 '26 11:10 juliusmarminge