Skip to content

Commit 09bea08

Browse files
committed
feat: add generate_object tool for structured JSON output
Add a built-in `generate_object` tool that produces schema-validated JSON objects from any LLM provider. Features: - Four output modes: tool-call (default), prompt, strict, json - Robust JSON extraction from dirty LLM output (code fences, prose) - Streaming partial objects via tool_output_delta events - Automatic repair loop with schema validation feedback - Built-in JSON Schema validator (anyOf/oneOf, nullable, pattern, ranges) - Cross-provider: works with Anthropic, OpenAI, and OpenAI-compatible APIs Includes 70 unit tests + 4 integration tests against real MiniMax API, Node.js SDK integration test (6 cases), and Python SDK integration test (6 cases). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 8eaf24f commit 09bea08

19 files changed

Lines changed: 3058 additions & 31 deletions

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [2.4.0] - 2026-05-11
11+
12+
### Added
13+
14+
- Added `generate_object` built-in tool for structured JSON output with schema
15+
validation, automatic repair, and streaming partial objects. Works across all
16+
providers via tool-calling mode.
17+
- Added `llm::structured` module with four output modes (tool, prompt, strict,
18+
json), robust JSON extraction from dirty LLM output, partial JSON parser for
19+
streaming, and a built-in JSON Schema validator supporting `anyOf`/`oneOf`,
20+
nullable types, `additionalProperties`, `pattern`, and numeric ranges.
21+
- Added streaming partial object support: `generate_object` emits
22+
`tool_output_delta` events with progressively complete JSON snapshots.
23+
- Added comprehensive documentation: structured output example (EN/CN), contract
24+
review tutorial (EN/CN), and 7 additional core mechanism tutorials (PTC,
25+
streaming, session persistence, skills, MCP, security/HITL, hooks, memory).
26+
27+
### Fixed
28+
29+
- Fixed Shiki build error in docs site caused by unsupported `acl` language
30+
identifier in code blocks (replaced with `text`).
31+
1032
## [2.3.0] - 2026-05-09
1133

1234
### Added

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "a3s-code-core"
3-
version = "2.3.0"
3+
version = "2.4.0"
44
edition = "2021"
55
authors = ["A3S Lab Team"]
66
license = "MIT"

core/src/agent_api/capabilities.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ pub(super) fn build_session_capabilities(input: SessionCapabilityInput<'_>) -> S
6060
&tool_executor,
6161
);
6262

63+
// Register generate_object tool (structured JSON output)
64+
crate::tools::register_generate_object(tool_executor.registry(), Arc::clone(&input.llm_client));
65+
6366
register_mcp_capabilities(
6467
&tool_executor,
6568
input.opts,

core/src/llm/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub mod anthropic;
77
pub mod factory;
88
pub mod http;
99
pub mod openai;
10+
pub mod structured;
1011
mod types;
1112
pub mod zhipu;
1213

0 commit comments

Comments
 (0)