Repository navigation
Move response formatting to root packages - #1345
Conversation
Extract shared response formats and JSON schema helpers from agent. Keep deprecated aliases and forwarding wrappers, update SDK and example consumers, and add compatibility coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the response-format package migration.
No open issues 🎉
What changed in this PR
Moves shared response-format types and JSON schema helpers into root packages so formatting and function tools no longer depend on agent, while preserving existing APIs through deprecated aliases and forwarding wrappers.
Changes:
- Introduces root
formatandformat/jsonformatpackages. - Migrates agent, provider, tool, and example code to the new packages.
- Relocates formatting tests and adds legacy API compatibility regression tests.
| File | Description |
|---|---|
tool/functool/func.go |
Uses root JSON formatting helpers. |
provider/openaiprovider/strict_schema_test.go |
Updates schema-test imports. |
provider/openaiprovider/responses.go |
Uses root formatting types and helpers. |
provider/openaiprovider/responses_test.go |
Updates Responses API test imports. |
provider/openaiprovider/chat.go |
Uses root formatting types and helpers. |
provider/openaiprovider/chat_test.go |
Updates Chat Completions test imports. |
provider/geminiprovider/agent.go |
Migrates Gemini formatting callbacks. |
provider/foundryprovider/agent_e2e_test.go |
Migrates Foundry test formatting types. |
provider/anthropicprovider/agent.go |
Migrates Anthropic formatting callbacks. |
format/jsonformat/structuredoutput.go |
Moves structured-output helpers to the root package. |
format/jsonformat/jsonformat.go |
Houses JSON format constructors and schema resolution. |
format/jsonformat/jsonformat_test.go |
Tests constructors in their new package. |
format/jsonformat/encoding.go |
Houses JSON encoding, normalization, and validation. |
format/jsonformat/encoding_test.go |
Migrates encoding tests to root types. |
format/jsonformat/doc.go |
Documents the root JSON formatting package. |
format/format.go |
Defines the shared response-format type. |
examples/02-agents/agents/step05_structured_output/main.go |
Demonstrates the new import path. |
agent/structuredoutput.go |
Uses root types in middleware callbacks. |
agent/structuredoutput_test.go |
Updates structured-output tests to root types. |
agent/options.go |
Uses the root type for response-format options. |
agent/format/jsonformat/jsonformat.go |
Preserves legacy APIs through aliases and wrappers. |
agent/format/jsonformat/jsonformat_test.go |
Adds legacy compatibility and error regression tests. |
agent/format/jsonformat/doc.go |
Documents the deprecated package’s replacement. |
agent/format.go |
Preserves agent.ResponseFormat as a deprecated alias. |
agent/agent.go |
Updates provider callback types. |
agent/agent_test.go |
Migrates agent formatting tests to root types. |
Review effort: Balanced
This comment has been minimized.
This comment has been minimized.
Disambiguate example imports using recorded Go target packages. Include root format packages in default indexing while retaining support for older checkouts, and add regression coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
API consistency review
Changed Go contractResponse-format descriptions and JSON schema helpers move into new top-level packages. The old agent-package APIs stay as deprecated type aliases and forwarding wrappers. The function tools and formatting code no longer depend on the agent package. Provider and example imports are updated. No runtime behavior, defaults, or option shapes change. Upstream evidence reviewedNo upstream files were read. The GitHub code search for the .NET and Python equivalents was rate-limited (HTTP 429), so I did not compare against them. AssessmentThe PR reorganizes Go packages to remove a dependency cycle. Package layout is a Go-specific concern. The old APIs are kept as aliases, so behavior should be unchanged, and I found no parity issue. The existing
|
Summary
Validation
go vetpasses for affected packages.