Skip to content

feat: add configurable effort levels for thinking budget#105

Open
guidan-nick wants to merge 5 commits into
tickernelz:masterfrom
guidan-nick:feature/effort-config
Open

feat: add configurable effort levels for thinking budget#105
guidan-nick wants to merge 5 commits into
tickernelz:masterfrom
guidan-nick:feature/effort-config

Conversation

@guidan-nick

Copy link
Copy Markdown

Summary

Add native Kiro effort parameter support to control thinking/reasoning depth. This fixes the issue where OpenCode's thinking budget settings are ignored because Kiro uses its own effort levels instead of Anthropic's budget_tokens/max_thinking_length.

Problem

When using thinking models (e.g., claude-opus-4-8-thinking) through the Kiro auth plugin, the thinking budget is capped at ~20k tokens regardless of OpenCode's max thinking setting. This is because Kiro ignores Anthropic's native thinking parameters and instead requires effort to be passed via additionalModelRequestFields.output_config.effort.

Solution

Inject the additionalModelRequestFields with the resolved effort level into API requests via SDK middleware.

Changes

  • schema.ts: Add effort and auto_effort_mapping config options
  • effort.ts: New module with budget-to-effort mapping logic
  • sdk-client.ts: Inject additionalModelRequestFields via middleware when effort is set
  • request.ts: Resolve effort based on model, thinking state, budget, and config
  • request-handler.ts: Pass config effort settings through request pipeline
  • types.ts: Add Effort type and extend SdkPreparedRequest

Effort Levels

Level Description Approximate Tokens
low Minimal reasoning -
medium Balanced (default) ~20k
high Deeper reasoning ~50k
xhigh Extended (opus-4.7/4.8 only) ~80k
max Maximum depth ~128k

Configuration

// kiro.json - explicit effort level
{
  "effort": "max"
}

// kiro.json - auto-map from OpenCode budget (default behavior)
{
  "auto_effort_mapping": true
}

Testing

  • Build passes (npm run build)
  • Added unit tests for effort resolution logic

References

Add native Kiro effort parameter support to control thinking/reasoning depth.
Kiro ignores Anthropic's budget_tokens/max_thinking_length and instead uses
its own effort levels (low/medium/high/xhigh/max) passed via
additionalModelRequestFields.output_config.effort.

Changes:
- Add effort and auto_effort_mapping config options to schema
- Add effort.ts with budget-to-effort mapping logic
- Modify sdk-client to inject additionalModelRequestFields via middleware
- Update request pipeline to resolve and pass effort through
- Add unit tests for effort resolution

Effort levels:
- low: minimal reasoning
- medium: balanced (default, ~20k tokens)
- high: deeper reasoning (~50k tokens)
- xhigh: extended (opus-4.7/4.8 only, ~80k tokens)
- max: maximum depth (128k tokens on opus-4.7/4.8)

Usage in kiro.json:
  { "effort": "max" }  // explicit effort level
  { "auto_effort_mapping": true }  // map OpenCode budget to effort (default)

Fixes thinking budget being capped at 20k regardless of OpenCode settings.
OpenCode sends thinkingBudget in body.thinkingConfig (not body.providerOptions.thinkingConfig).
Update budget extraction to check both locations.

Also update budget-to-effort mapping to align with OpenCode's standard variant values:
- 8192 (low) -> effort low
- 16384 (medium) -> effort medium
- 24576 (high) -> effort high
- 32768 (max) -> effort max
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