feat: add schema-driven reasoning and improve agent reliability - #6
Open
trankien84 wants to merge 5 commits into
Open
feat: add schema-driven reasoning and improve agent reliability#6trankien84 wants to merge 5 commits into
trankien84 wants to merge 5 commits into
Conversation
Normalize Claude thinking.type=enabled to a model-supported adaptive type before schema validation. Keep strict validation for unsupported thinking types, effort levels, display values, and budget fields, and add regression coverage for Claude and OpenAI-compatible reasoning requests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds runtime schema-driven native reasoning support and improves reliability for long-running agent workflows.
The main changes are:
1. Schema-driven native reasoning
Problem
Kiro exposes model-specific request capabilities through
additionalModelRequestFieldsSchema, but the proxy did not preserve or use that schema when building requests.As a result:
-thinkingsuffix relied mainly on prompt injection instead of model-native request fields.Solution
The proxy now preserves
additionalModelRequestFieldsSchemafromListAvailableModelsand parses it at runtime.The parsed capability includes:
budget_tokens;output_config.effort, orreasoning.effort;low,medium,high,xhigh, andmax.Requested values are validated against the selected model's schema before the upstream request is sent.
API coverage
Native reasoning is supported across:
The generated fields are forwarded through
additionalModelRequestFields.Backward compatibility
The configured thinking suffix, such as
-thinking, remains supported.When compatible native reasoning fields are available, they are forwarded directly and the legacy thinking prompt is not injected.
When native fields are unavailable, the existing legacy thinking prompt remains the fallback.
2. Environment-gated diagnostics
Problem
Investigating issues such as truncated payloads, incomplete streams, reasoning forwarding, and chunk normalization previously required adding temporary logs directly to the request path.
Solution
This PR adds opt-in diagnostic flags:
KIRO_DIAGNOSTICSfalseKIRO_DIAG_STREAMfalseKIRO_DIAG_PAYLOADfalseKIRO_DIAG_REASONINGfalseKIRO_DIAG_CHUNKSfalseAccepted enabled values are
1,true,yes,on, andenabled.KIRO_DIAGNOSTICSintentionally does not enableKIRO_DIAG_CHUNKS, because chunk logs may contain prompts, reasoning, source code, or tool output.All diagnostics remain disabled by default.
3. Agent tool-execution reliability
Problem
During coding-agent workflows, a model may describe or plan a tool action without actually invoking the required tool, causing the turn to end before the requested work is complete.
Solution
Tool-enabled agent requests now include execution guidance that instructs the model to:
A shorter reminder is also added on continued tool turns when pending work still requires tool execution.
The guidance is not added when tool use is explicitly disabled through
tool_choice.4. Stream and region reliability
Longer streaming timeout
The Kiro streaming HTTP timeout is increased from 5 minutes to 15 minutes to support long-running coding-agent operations.
The separate REST client keeps its existing 30-second timeout.
IDC and external IdP region probing
For
idcandexternal_idpaccounts, the authentication region may differ from the Kiro profile region.Profile discovery can now probe configured fallback regions for these account types when resolving the profile ARN.
Once a profile ARN is resolved, its region continues to determine the data-plane endpoint.
5. Payload and stream diagnostics
Payload diagnostics report:
The diagnostics wrap the existing byte-and-token-aware truncation logic without changing its preservation rules.
Stream diagnostics report aggregate information such as:
Raw chunk previews remain separately opt-in.
Changes
ListAvailableModels.README.md.Tests
Added and updated tests covering:
output_config.effort;reasoning.effort;Verification performed:
gofmtgo test ./...go vet ./...git diff --check zsec/main --Compatibility notes
-thinkingmodel suffixes remain supported.