Skip to content

feat: v0.17.3 — Agent Runtime Controls#26

Merged
johnnichev merged 3 commits intomainfrom
feat/agent-runtime-controls
Mar 22, 2026
Merged

feat: v0.17.3 — Agent Runtime Controls#26
johnnichev merged 3 commits intomainfrom
feat/agent-runtime-controls

Conversation

@johnnichev
Copy link
Copy Markdown
Owner

Summary

  • R1: Token Budget Per Runmax_total_tokens and max_cost_usd on AgentConfig with BUDGET_EXCEEDED trace step and observer event
  • R2: Agent CancellationCancellationToken (thread-safe) checked at iteration boundaries and after tool execution
  • R4: SimpleStepObserver — routes all 30 observer events to a single callback
  • R7: Cost Attributioncost_usd field on TraceStep for LLM_CALL steps
  • R8: Structured Tool Results — auto-serializes dict/list/Pydantic/dataclass returns as JSON
  • R9: Per-Tool Approval Gaterequires_approval flag on @tool() decorator

Test plan

  • 61 new tests covering all 6 features
  • Full suite passes: 1908 tests, 0 failures
  • Pre-commit hooks pass (black, isort, flake8, mypy, bandit)

🤖 Generated with Claude Code

v0.17.3 Agent Runtime Controls: token budget, cancellation, cost
attribution, structured tool results, per-tool approval, SimpleStepObserver.
v0.17.4 Agent Intelligence: token estimation, model switching, knowledge
memory enhancement with 4 store backends.
Multi-agent orchestration moved from v0.17.2 to v0.18.0.
R7: Tool-level cost attribution — cost_usd field on TraceStep, populated
    on LLM_CALL steps from provider usage stats.

R8: Structured tool results — Tool._serialize_result() auto-serializes
    dict, list, Pydantic, and dataclass returns as JSON instead of str().

R9: Per-tool approval gate — requires_approval flag on @tool() decorator
    and Tool class. Overrides policy ALLOW → REVIEW for flagged tools.

R4: SimpleStepObserver — convenience observer that routes all 30 lifecycle
    events to a single callback(event_name, run_id, **kwargs).

R1: Token budget per run — max_total_tokens and max_cost_usd on AgentConfig.
    Agent loop checks budget at each iteration start; returns partial result
    with BUDGET_EXCEEDED trace step and on_budget_exceeded observer event.

R2: Agent cancellation — CancellationToken (thread-safe) checked at iteration
    boundaries and after tool execution. CANCELLED trace step, on_cancelled
    observer event. Token is reusable via reset().

New StepTypes: BUDGET_EXCEEDED, CANCELLED (16 total).
New exports: CancellationToken, CancellationError, BudgetExceededError,
    SimpleStepObserver.
6 features: token budget, cancellation, cost attribution, structured
tool results, per-tool approval gate, SimpleStepObserver.
61 new tests (total: 1908).
@johnnichev johnnichev merged commit 4bfa7d4 into main Mar 22, 2026
1 check passed
@johnnichev johnnichev deleted the feat/agent-runtime-controls branch March 22, 2026 22:43
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