Skip to content

feat(task): surface nesting depth and parent task id to the model - #16

Merged
easonLiangWorldedtech merged 1 commit into
main-task-treefrom
pr-7-depth-context
Aug 16, 2026
Merged

feat(task): surface nesting depth and parent task id to the model#16
easonLiangWorldedtech merged 1 commit into
main-task-treefrom
pr-7-depth-context

Conversation

@easonLiangWorldedtech

Copy link
Copy Markdown
Owner

feat(task): surface nesting depth and parent task id to the model

Problem

getEnvironmentDetails() never told a subtask where it sits in the delegation tree. A child had no way to know its own depth or parentTaskId, so live tests showed models guessing their level from user wording ("我判斷自己處於頂層會話") — depth-3/4 probes were unanswerable by design, and PR-1's persisted depth was invisible to the agent.

Change

Append a small # Task Context section to the environment details block in getEnvironmentDetails.ts, right after Current Mode:

# Task Context
Nesting depth: 2 (root = 0)
Parent task: <parentTaskId>   ← only when this is a child
  • Reads fields already on the Task (depth, parentTaskId) — zero plumbing, no new state.
  • Gated on typeof cline.depth === "number" so partial test doubles without depth are unaffected (existing 21 tests unchanged).
  • Deliberately does not resolve the parent's title: that would need a history-store lookup on every environment refresh; the id is enough for the model to reason about lineage.

Tests

3 new cases in getEnvironmentDetails.spec.ts:

  • root task (depth 0) → section present, no parent line
  • child task (depth 2 + parentTaskId) → depth and parent id both surfaced
  • unknown depth (undefined) → section omitted entirely

Suite: 24/24 pass. check-types 11/11. Per-file eslint clean.

@easonLiangWorldedtech
easonLiangWorldedtech merged commit 39afe46 into main-task-tree Aug 16, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants