Add TODOS checklist and DELEGATE context-isolated subtask features#104
Merged
Conversation
Three agent-workflow enhancements, implemented in both the Python harness
(clk_harness/) and the TypeScript pi-extension for parity.
1. TODOS checklist — a mutable per-turn checklist ([ ]/[~]/[x]) the agent
re-emits each turn, filling the gap between append-only PROGRESS.md and
the heavyweight charter/plan. Mirrors the POST: pipeline but with
last-write-wins storage (.clk/state/todos.json, keyed by author).
- Python: new orchestration/todos.py; _apply_todos hook in transcript.py
wired into _dispatch_once; $todos injected per-author in prompts.py;
_TODOS_PROTOCOL_BLOCK in _BASE_FOOTER; malformed_todos quality check.
- pi: TodoItem type, setTodos (state.ts), clk_todos tool, primer note.
2. Context-offload discipline — a scratch/ convention plus guidance to park
big blobs in files and read back only slices (grep/head/sed). No sandbox
change needed; scratch/ is git-ignored so the per-run `git add -A`
auto-commit can't sweep it in.
- Python: prose in _BASE_FOOTER; scratch/ in .gitignore.
- pi: prose in the operator manual; scratch/ in HARDENED_GITIGNORE and
the extension .gitignore.
3. DELEGATE sub-agent — a context-isolated child that does a bounded
subtask and returns a distilled result. Isolation withholds the caller's
blackboard; the child's own posts are suppressed; it may do real work
(commit files) and its result returns as one delegate_result post.
Depth-capped (default 1) with cycle/self/unknown-target guards.
- Python: DelegateProposal + parse_delegate_proposals (director.py);
"delegate" in _META_PHASES; isolation branch in _collect_context;
post-suppression in _apply_posts; _apply_delegate hook; max_delegate_depth
config with .env.example/kickoff.py/docs parity; _DELEGATE_PROTOCOL_BLOCK.
- pi: runDelegate (consensus.ts) + clk_delegate tool built on spawnSubagent
(already context-isolated); quick-reference entry.
Tests: new tests/test_todos.py, tests/test_delegate_parser.py, TODOS+DELEGATE
integration tests, malformed_todos and scratch/ cases; pi tests/todos.test.ts,
tests/delegate.test.ts, extended prompts.test.ts. pi test:strict green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KUsgsFFA4ovessfnpsesTW
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces two new agent coordination primitives to the CLK orchestration framework:
TODOS: A lightweight, mutable per-turn checklist that sits between the append-only progress log and heavyweight charter/plan. Agents maintain a short list of items (todo/doing/done) that overwrites on each emission (last-write-wins).
DELEGATE: A context-isolation mechanism for bounded subtasks. An agent can hand off a self-contained task to a child agent that runs in a fresh session without access to the caller's blackboard, but may perform real work (file writes/commits). The child's distilled result returns as a single post.
Key Changes
TODOS Checklist System
New module
clk_harness/orchestration/todos.py: Complete TODOS implementation with parsing, persistence, and renderingparse_todos_blocks(): Extracts checklist items from agent responses (last complete block wins)apply_todos_blocks(): Persists per-author checklists to.clk/state/todos.json(mutable, last-write-wins)render_todos(): Formats checklist for prompt injection via$todosplaceholderIntegration points:
TranscriptMixin._apply_todos(): Parses and persists TODOS blocks from agent responses (skipped in meta phases)PromptsMixin._collect_context(): Injects agent's current checklist into next promptrunner.py: Added_todos_lockfor thread-safe concurrent access_TODOS_PROTOCOL_BLOCKdocumentation to promptsTests: Comprehensive unit tests in
tests/test_todos.pycovering parsing, persistence, and renderingDELEGATE Context-Isolation System
New parser
parse_delegate_proposals()incasting/director.py: Extracts DELEGATE blocks with target, context, and taskCore implementation
TranscriptMixin._apply_delegate():max_delegate_depth, default 1) and per-turn limit (max_delegates_per_turn, default 2)delegate_resultpostConfiguration: New robustness settings in
clk.config.json:max_delegate_depth: Nesting limit (default 1)max_delegates_per_turn: Per-turn dispatch cap (default 2)delegate_result_max_chars: Result truncation cap (default 2000)Tests: Integration tests in
tests/test_robustness_integration.pyand unit tests intests/test_delegate_parser.pyPI Extension (TypeScript)
clk_todos: Allows agents to update their checklist with status marks ([ ]/[~]/[x])clk_delegate: Dispatches bounded subtasks to context-isolated childrensetTodos()andgetTodos()instate.tsfor checklist persistencerunDelegate()function that constructs isolation preamble and distillation instructionsQuality & Response Validation
response_quality.py: Added malformed TODOS block detection (balancedTODOS:/END_TODOScheck)Configuration & Documentation
.env.examplewith new DELEGATE settingsCONFIGURATION.mdwith robustness tuning guidance.gitignoreto excludescratch/(context-offload working directory)Implementation Details
https://claude.ai/code/session_01KUsgsFFA4ovessfnpsesTW