Skip to content

release: v0.16.3 — agent refactoring + astream() full parity#5

Merged
johnnichev merged 1 commit intomainfrom
release/v0.16.3
Mar 15, 2026
Merged

release: v0.16.3 — agent refactoring + astream() full parity#5
johnnichev merged 1 commit intomainfrom
release/v0.16.3

Conversation

@johnnichev
Copy link
Copy Markdown
Owner

Summary

  • Refactored Agent class — extracted _RunContext, _prepare_run(), _finalize_run(), _process_response(), _build_max_iterations_result() shared helpers, eliminating ~800 lines of duplicated setup/teardown/iteration logic across run(), arun(), and astream()
  • Fixed 14+ astream() feature gaps — input/output guardrails, knowledge/entity/KG context, session save, coherence checks, output screening, analytics, structured output, reasoning extraction, trace steps, and full AgentResult fields
  • Added multi-agent pre-workAgent.name, Agent.__call__(), parent_run_id param, GraphExecutionError, _clone_for_isolation()

Test plan

  • All 1462 existing tests pass (zero regressions)
  • 29 new regression tests in tests/agent/test_astream_parity.py
  • black, isort, flake8, mypy all clean
  • mkdocs build succeeds with no new warnings
  • Pre-commit hooks all pass

🤖 Generated with Claude Code

Refactor Agent class to eliminate ~800 lines of duplicated setup/teardown
logic across run(), arun(), and astream() via shared helpers. Fix 14+
feature gaps in astream() that made it a second-class execution method.

Added:
- Agent.name property, Agent.__call__() shorthand
- parent_run_id param on run/arun/astream for trace linking
- response_format param on astream (was missing)
- GraphExecutionError exception (v0.17.0 pre-work)
- _RunContext dataclass + _prepare_run/_finalize_run/_process_response helpers
- _clone_for_isolation() for batch processing
- 29 regression tests (tests/agent/test_astream_parity.py)

Fixed (astream parity):
- Input/output guardrails, knowledge/entity/KG context injection
- Session load/save, memory summary, coherence checks
- Tool output screening, analytics, verbose output, chunk callback
- Structured output validation, reasoning extraction, tool_selection traces
- Tool-not-found and policy denial trace steps, per-tool usage tracking
- History append order, full AgentResult fields

Docs: Updated AGENT.md, EXCEPTIONS.md, ARCHITECTURE.md, index.md,
README.md, CLAUDE.md with new features and corrected counts.
@johnnichev johnnichev merged commit 41e4725 into main Mar 15, 2026
1 check passed
@johnnichev johnnichev deleted the release/v0.16.3 branch March 15, 2026 00:42
johnnichev added a commit that referenced this pull request Mar 24, 2026
Security:
- Path traversal in JsonFileSessionStore — validate session_id (#9)
- Unicode homoglyph bypass in injection screening — NFKD + zero-width
  strip + homoglyph map (#13)

Data integrity:
- FileKnowledgeStore._save_all() atomic write via tmp + os.replace (#10)
- JsonFileSessionStore.save() atomic write (#31)

Agent core:
- astream() uses self._effective_model (was self.config.model) (#1)
- Sync _check_policy rejects async confirm_action with clear error (#2)
- Sync _streaming_call isinstance(chunk, str) guard (#18)

Providers:
- FallbackProvider stream()/astream() record success after consumption,
  not before — circuit breaker now works for streaming (#3)
- Gemini response.text ValueError catch for tool-call-only responses (#4)

Tools:
- aexecute() uses run_in_executor(None) shared executor (#5)
- execute() awaits coroutines from async tools via asyncio.run (#6)

RAG:
- Hybrid search O(n²) → O(1) via text_to_key dict lookup (#7)
- SQLiteVectorStore thread safety + WAL mode (#8)

Evals:
- OutputEvaluator catches re.error on invalid regex (#11)
- JsonValidityEvaluator respects expect_json=False (#12)

16 new regression tests. Full suite: 2000 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