Skip to content

v0.8.68 Runtime: make current Work state model-visible on parent turns #3983

Description

@Hmbown

Problem

CodeWhale already has a useful Work surface: checklist_* is the counted execution ledger and update_plan carries strategy metadata. The TUI shows this as To-do plus Strategy context, and forked sub-agents receive a synthesized Fork State block.

The part that still needs hardening is parent-turn grounding. Today the parent model can create/update the state through tools and can see tool results in the transcript, but the repo evidence I found does not show an equivalent synthesized current Work-state block being injected into normal parent turns after long sessions, resume, compaction, or drift. If we want to describe this as dynamic planning rather than a nice UI projection, the parent model should reliably receive the live checklist/strategy state too.

Evidence

Implemented today:

  • crates/tui/src/prompts/constitution.md teaches agents to use checklist_write and optionally update_plan for multi-phase work.
  • crates/tui/src/prompts/modes/agent.md, plan.md, and yolo.md repeat that guidance per mode.
  • crates/tui/src/tools/registry.rs exposes canonical checklist_* tools to the model catalog while keeping legacy todo_* aliases hidden.
  • crates/tui/src/tools/plan.rs stores rich PlanArtifact fields and returns the updated snapshot in the tool result.
  • crates/tui/src/tools/todo.rs stores checklist progress metadata under task_updates.checklist.
  • crates/tui/src/tui/sidebar.rs renders the combined Work projection as checklist plus Strategy context.
  • crates/tui/src/core/engine.rs captures todo_snapshot and plan_snapshot into StructuredState.
  • crates/tui/src/tools/subagent/mod.rs wraps that state in <codewhale:fork_state> for forked sub-agents.
  • crates/tui/src/commands/groups/session/relay.rs includes checklist and strategy metadata in manual relay output.

Gap to close:

  • The normal parent turn path in crates/tui/src/core/engine.rs adds the user's message and then sends the transcript/tool catalog into handle_deepseek_turn; I did not find a matching synthesized current Work-state injection for the parent model outside the sub-agent fork path.
  • Relying only on old tool results in the transcript is weaker during long sessions, compaction, resume, and model drift. The live sidebar can be correct while the next model call is not explicitly reminded of the current Work state.

Expected behavior

At the start of a parent model turn, when checklist or plan state exists, CodeWhale should provide a compact, current, model-visible Work-state block. It should be concise, deterministic, and not duplicate the entire transcript.

Suggested shape:

<codewhale:work_state>
Checklist (38% complete)
- [x] ...
- [~] ...
- [ ] ...

Strategy metadata
- Objective: ...
- Context: ...
- Constraint: ...
- Recommended approach: ...
- Verification plan: ...
- [~] phase now ...
- [ ] phase next ...
</codewhale:work_state>

The block should be injected only when non-empty, should avoid secrets, and should stay small enough not to fight the context budget.

Likely files

  • crates/tui/src/core/engine.rs
  • crates/tui/src/core/engine/turn.rs
  • crates/tui/src/tools/plan.rs
  • crates/tui/src/tools/todo.rs
  • crates/tui/src/tools/subagent/mod.rs
  • crates/tui/src/commands/groups/session/relay.rs
  • Prompt/context tests under crates/tui/src/prompts.rs, crates/tui/src/core/engine.rs, or focused engine tests

Acceptance criteria

  • Parent model requests include a compact current Work-state block when checklist or strategy metadata exists.
  • The block includes checklist status/progress and high-value strategy metadata, but does not duplicate the entire transcript or every prior tool output.
  • Sub-agent fork-state and /relay continue to use compatible wording so the three continuity paths do not drift.
  • Add tests that fail if Work state is only rendered in the UI but omitted from model-facing parent-turn context.
  • Add or update product/docs copy only after the runtime behavior is covered by tests, so the public claim stays grounded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationImprovements or additions to documentationenhancementNew feature or requestv0.8.69Targeting v0.8.69workflow-runtimeWorkflow IR, executor, control flow, and replay runtime

    Projects

    Status
    Backlog

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions