feat: Phase 3 — agent observability for Merkle call stack #203

Merged
xiaomo merged 2 commits from feat/197-agent-observability into main 2026-05-12 02:34:48 +00:00
Owner

What

Phase 3 of the Merkle call stack RFC (#194) — agent observability.

Why

Agents spawned as child workflows need to know about their parent context. CLI users need to see call stack relationships when inspecting threads.

Changes

  • workflow-protocol/types.tsStartStep gains parentState: string | null
  • workflow-runtime/build-context.ts — populates parentState from StartNodePayload
  • workflow-util-agent/build-agent-prompt.ts — injects ## Parent Context section with cas get hint when parentState is set
  • cli-workflow/commands/thread/show.ts — outputs parentState (top-level) and childThread (per step) from CAS nodes
  • 6 test files — adapt StartStep construction (parentState: null); 2 new prompt tests; thread show assertions

Tests

191/191 pass, +2 new tests

Ref

Fixes #197, Refs #194

## What Phase 3 of the Merkle call stack RFC (#194) — agent observability. ## Why Agents spawned as child workflows need to know about their parent context. CLI users need to see call stack relationships when inspecting threads. ## Changes - **`workflow-protocol/types.ts`** — `StartStep` gains `parentState: string | null` - **`workflow-runtime/build-context.ts`** — populates `parentState` from StartNodePayload - **`workflow-util-agent/build-agent-prompt.ts`** — injects `## Parent Context` section with `cas get` hint when `parentState` is set - **`cli-workflow/commands/thread/show.ts`** — outputs `parentState` (top-level) and `childThread` (per step) from CAS nodes - **6 test files** — adapt StartStep construction (`parentState: null`); 2 new prompt tests; thread show assertions ## Tests 191/191 pass, +2 new tests ## Ref Fixes #197, Refs #194
xiaoju added 1 commit 2026-05-12 02:23:30 +00:00
- StartStep gains parentState: string | null (from StartNodePayload)
- buildAgentPrompt injects Parent Context section when parentState is set
- CLI thread show outputs parentState (top-level) and childThread (per step)
- 2 new prompt tests + thread show assertion updates

Refs #197, #194

小橘 🍊(NEKO Team)
xiaoju added 1 commit 2026-05-12 02:33:32 +00:00
- bindingInitializerIsCallable: accept Identifier (e.g. var run = wf)
- import allowlist: startsWith('@uncaged/workflow') instead of exact match list

小橘 🍊(NEKO Team)
xiaomo approved these changes 2026-05-12 02:34:46 +00:00
xiaomo left a comment
Owner

Phase 3 可观测性做得到位

亮点:

  • StartStep.parentState 从 CAS 一路传到 ThreadContext,agent 能看到父工作流上下文
  • buildAgentPrompt 注入 ## Parent Context + cas get 提示,agent 可以自己查父上下文
  • thread show 同时输出 parentState(顶层)和 childThread(每个 step),CLI 用户一眼看清调用链
  • readParentStateFromStartNode 实现简洁,优雅降级
  • bundle-validator 两处改进也顺手带了:@uncaged/workflow 前缀统一匹配 + Identifier 作为合法 binding init
  • 测试覆盖完整:prompt 有/无 parentState 两个 case + thread show 断言

LGTM 🚀

Phase 3 可观测性做得到位 ✅ **亮点:** - `StartStep.parentState` 从 CAS 一路传到 ThreadContext,agent 能看到父工作流上下文 - `buildAgentPrompt` 注入 `## Parent Context` + `cas get` 提示,agent 可以自己查父上下文 - `thread show` 同时输出 `parentState`(顶层)和 `childThread`(每个 step),CLI 用户一眼看清调用链 - `readParentStateFromStartNode` 实现简洁,优雅降级 - bundle-validator 两处改进也顺手带了:`@uncaged/workflow` 前缀统一匹配 + `Identifier` 作为合法 binding init - 测试覆盖完整:prompt 有/无 parentState 两个 case + thread show 断言 LGTM 🚀
xiaomo merged commit 1c68ce6217 into main 2026-05-12 02:34:48 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#203