consciousness/src/agent
Kent Overstreet f1397b7783 Redesign context AST: typed NodeBody, Role as grammar roles, tests
Role is now just System/User/Assistant — maps 1:1 to the grammar.
Leaf types are NodeBody variants: Content, Thinking, ToolCall,
ToolResult, Memory, Dmn, Log. Each variant renders itself; no Role
needed on leaves. AstNode is Leaf(NodeLeaf) | Branch{role, children}.
ContextState holds four Vec<AstNode> sections directly.

Moved tool call XML parsing from api/parsing.rs into context_new.rs
so all grammar knowledge lives in one place.

Tokenizer encode() now returns empty vec when uninitialized instead
of panicking, so tests work without the tokenizer file.

26 tests: XML parsing, incremental streaming (char-by-char feeds
found and fixed a lookahead bug), rendering for all node types,
tokenizer round-trip verification.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-04-08 13:35:04 -04:00
..
api ContextState + private AstNode fields: enforce token_ids invariant 2026-04-08 12:58:59 -04:00
tools Agent-aware provenance for memory tools 2026-04-07 17:46:40 -04:00
context.rs Kill tiktoken — all token counting now uses Qwen 3.5 tokenizer 2026-04-08 11:25:28 -04:00
context_new.rs Redesign context AST: typed NodeBody, Role as grammar roles, tests 2026-04-08 13:35:04 -04:00
mod.rs WIP: Context AST design — AstNode with Leaf{text,token_ids}/Branch 2026-04-08 12:46:44 -04:00
oneshot.rs Fix bail script: pass own pid file so it can exclude itself 2026-04-08 09:35:52 -04:00
tokenizer.rs Redesign context AST: typed NodeBody, Role as grammar roles, tests 2026-04-08 13:35:04 -04:00