consciousness/src/subconscious
Kent Overstreet 5e4067c04f Replace token counting with token generation via HuggingFace tokenizer
Add agent/tokenizer.rs with global Qwen 3.5 tokenizer that generates
actual token IDs including chat template wrapping. ContextEntry now
stores token_ids: Vec<u32> instead of tokens: usize — the count is
derived from the length.

ContextEntry::new() tokenizes automatically via the global tokenizer.
ContextSection::push_entry() takes a raw ConversationEntry and
tokenizes it. set_message() re-tokenizes without needing an external
tokenizer parameter.

Token IDs include the full chat template: <|im_start|>role\ncontent
<|im_end|>\n — so concatenating token_ids across entries produces a
ready-to-send prompt for vLLM's /v1/completions endpoint.

The old tiktoken CoreBPE is now unused on Agent (will be removed in
a followup). Token counts are now exact for Qwen 3.5 instead of the
~85-90% approximation from cl100k_base.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
2026-04-08 11:20:03 -04:00
..
agents Fix restore_from_log panic on Thinking entries, fix bail nullglob 2026-04-08 10:39:07 -04:00
audit.rs Kill log callback — use ConversationEntry::Log for debug traces 2026-04-07 01:23:22 -04:00
consolidate.rs Reduce pub visibility: hippocampus, subconscious internals 2026-04-07 17:29:12 -04:00
daemon.rs Kill log callback — use ConversationEntry::Log for debug traces 2026-04-07 01:23:22 -04:00
defs.rs Reduce pub visibility: hippocampus, subconscious internals 2026-04-07 17:29:12 -04:00
digest.rs Fix build warnings across workspace 2026-04-07 13:55:30 -04:00
learn.rs Replace token counting with token generation via HuggingFace tokenizer 2026-04-08 11:20:03 -04:00
mod.rs Fix: reap stale agent pid files in poc-hook 2026-04-07 13:27:59 -04:00
prompts.rs Reduce pub visibility: hippocampus, subconscious internals 2026-04-07 17:29:12 -04:00