feat(llm9p): per-session compact and usage files for context window management Add automatic context window compaction support to the per-session 9P API: - session.go: Add Session.EstimatedContextTokens() (4 chars/token heuristic over current messages — more accurate than cumulative totalTokens for threshold decisions). Add SessionManager.Compact(ctx, id) which summarises the conversation via AskWithRequest then replaces session.messages with a compact 2-message exchange. Add SessionManager.EstimatedContextTokens(id) and SessionManager.ContextLimit() (200K for all Claude models). - session_compact.go: New /n/llm/N/compact file. Write any content to trigger Compact() for that session. Follows the SessionModelFile pattern. - session_usage.go: New /n/llm/N/usage file. Read returns "estimated_tokens/200000\n". Follows the SessionModelFile pattern. - session_dir.go: Wire compact and usage into Children() and Lookup(). Also land two pre-existing uncommitted fixes: - cli_client.go: Accept result messages with empty Result field - protocol.go: Increase MaxMessageSize 8192→65536 for large system prompts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
feat(llm9p): Implement clone-based session architecture Replace per-fid session model with Plan 9 clone pattern: - Reading /n/llm/new creates a session and returns its ID - Each session gets its own directory: /n/llm/<id>/ - Per-session files: ask, ctl, model, system, thinking, context, metrics - AskWithRequest method for stateless CSP-style LLM calls - Session settings (model, temperature, thinking) are per-session - Remove old ask.go, context.go in favor of session-scoped files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
feat(llm9p): Add per-fid session isolation and prefill support - Add SessionManager for per-fid conversation isolation - Each 9P fid now gets its own conversation history - Add FidAwareFile interface for files needing fid context - Add /n/llm/prefill file for assistant response prefill - Prefill helps keep model in character (e.g., "[Veltro]") - Update ask, new, context files to use session manager - Fix context contamination between parent and subagent Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
feat: Initial implementation of llm9p - LLM as 9P filesystem Exposes Claude as a 9P filesystem, enabling interaction through standard file operations: - ask: write prompt, read response (shim pattern) - model: read/write current model name - temperature: read/write sampling temperature - tokens: read-only token count from last response - new: write to reset conversation - context: read JSON history, write to add system message - _example: usage documentation - stream/chunk: blocking read for streaming responses Includes: - Full 9P2000 protocol implementation (stdlib only) - Anthropic SDK integration with conversation state - Streaming support Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>