Skip to content

feat: v0.17.4 — Agent Intelligence#27

Merged
johnnichev merged 2 commits intomainfrom
feat/agent-intelligence
Mar 22, 2026
Merged

feat: v0.17.4 — Agent Intelligence#27
johnnichev merged 2 commits intomainfrom
feat/agent-intelligence

Conversation

@johnnichev
Copy link
Copy Markdown
Owner

Summary

  • R6: Token Estimationestimate_tokens() and estimate_run_tokens() with tiktoken/heuristic fallback and TokenEstimate breakdown
  • R10: Model Switchingmodel_selector callback on AgentConfig, _effective_model throughout provider caller, on_model_switch observer event
  • R3: Knowledge MemoryKnowledgeEntry with importance/TTL/categories, KnowledgeStore protocol, FileKnowledgeStore + SQLiteKnowledgeStore backends, importance-based eviction

Test plan

  • 58 new tests covering all 3 features
  • Full suite passes: 1966 tests, 0 failures
  • Pre-commit hooks pass (black, isort, flake8, mypy, bandit)
  • Backward compatibility verified for KnowledgeMemory

🤖 Generated with Claude Code

R6: Token estimation — estimate_tokens() and estimate_run_tokens() for
    pre-execution budget checks. Uses tiktoken when available, falls back
    to chars/4 heuristic. TokenEstimate dataclass with breakdown.

R10: Model switching per iteration — model_selector callback on AgentConfig.
     _effective_model property replaces self.config.model in provider caller.
     on_model_switch observer event. Reset between runs via _prepare_run().

R3: Knowledge memory enhancement — KnowledgeEntry dataclass with importance
    scoring, TTL, and category. KnowledgeStore protocol with FileKnowledgeStore
    and SQLiteKnowledgeStore backends. Importance-based eviction at max_entries.
    Backward-compatible: existing KnowledgeMemory(directory=...) API unchanged.

New exports: TokenEstimate, estimate_tokens, estimate_run_tokens,
    KnowledgeEntry, KnowledgeStore, FileKnowledgeStore, SQLiteKnowledgeStore.
3 features: token estimation, model switching, knowledge memory enhancement.
58 new tests (total: 1966).
@johnnichev johnnichev merged commit 3d9911c into main Mar 22, 2026
1 check passed
@johnnichev johnnichev deleted the feat/agent-intelligence branch March 22, 2026 22:58
johnnichev added a commit that referenced this pull request Mar 24, 2026
Agent core observers (6 fixes):
- astream() cancellation/budget paths now build proper results with
  trace steps and async observer events (#14)
- arun() fires async observers for cancel/budget/max-iter (#15)
- _aexecute_tools_parallel fires async observer events (#16)
- _aexecute_tools_parallel tracks tool_usage/tool_tokens (#17)
- _acheck_policy fires async on_policy_decision observer (#10M)
- astream() max-iter path fires async on_run_end (#12M)

Tools + providers (7 fixes):
- Anthropic empty content list guard (#19)
- Bool rejected for int/float params (#20)
- ToolRegistry.tool() has screen_output/terminal/requires_approval (#21)
- MultiMCPClient list_all_tools() copies tools before prefixing (#22)
- Streamable-http 3-tuple unpacking robust handling (#23)
- _serialize_result returns "" for None (#24)
- StructuredOutputEvaluator handles __slots__ (#45)

RAG (6 fixes):
- SQLiteVectorStore search documented limitation (#25)
- InMemoryVectorStore max_documents warning (#26)
- Pinecone metadata.get instead of .pop (#27)
- ContextualChunker None content guard (#28)
- Filter overfetch: top_k*4 when filter present (#29)
- OpenAI embed_texts batching at 2048 (#30)

Memory (5 fixes):
- FileKnowledgeStore reads under lock (#32)
- SQLiteSessionStore WAL mode (#33)
- SQLiteKnowledgeStore indexes on query columns (#34)
- query() LIMIT after TTL filter (#35)
- Redis save() category update in pipeline (#36)

Evals (4 fixes):
- 16 LLM evaluators fail on unparseable score (#37)
- XSS fix: textContent instead of innerHTML (#38)
- Donut SVG 360° arc: two semicircles (#39)
- Suite completed counter under threading.Lock (#46)

Security (5 fixes):
- REWRITE/WARN guardrails tracked in trace (#40)
- SSN regex requires consistent separators (#41)
- Topic guardrail Unicode normalization (#42)
- Coherence usage tracked in agent costs (#43)
- Coherence fail_closed option (#44)

Full suite: 2013 passed.
johnnichev added a commit that referenced this pull request Mar 24, 2026
HIGH fixes recovered:
- Bug #22: MultiMCPClient copy.copy(tool) before prefix mutation
- Bug #26: InMemoryVectorStore max_documents capacity warning
- Bug #27: Pinecone metadata.get not .pop (stops mutating response)
- Bug #28: ContextualChunker (content or "").strip() None guard
- Bug #29: InMemoryVectorStore overfetch top_k*4 when filter present
- Bug #36: Redis save() category srem moved into pipeline
- Bug #38: XSS fix — createElement/textContent replaces innerHTML
- Bug #41: SSN regex uses strict alternation (?:\d{3}-\d{2}-\d{4}|\d{9})

LOW fix:
- Bug #35: KnowledgeMemory.remember() uses UTC consistently
- Fixed naive/aware datetime comparison in prune_old_logs
- Updated tests to use UTC dates

Full suite: 2013 passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant