You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8f4368d
Browse filesBrowse the repository at this point in the historyBrowse files
Delegate built-in reasoning configuration to pi-ai instead of rewriting
provider request payloads in the model catalog. This preserves existing
OpenAI/Codex/Anthropic reasoning defaults while letting pi-ai own
provider-specific payload shapes like OpenAI reasoning summaries and
Anthropic adaptive thinking.
## Root Cause
The built-in model catalog was using `onPayload` to manually mutate raw
provider request bodies for reasoning models. That duplicated
provider-specific behavior that pi-ai already implements, and made fixes
like Anthropic adaptive thinking and OpenAI reasoning summaries easy to
drift or conflict.
## Approach
- Add first-class `reasoning` and `thinkingBudgets` fields to
`AgentConfig`.
- Pass those fields through `context-factory` into
`createPiAgentAdapter`.
- Forward configured reasoning options into pi-ai stream calls.
- Remove built-in OpenAI/Codex/Anthropic reasoning payload rewriting
from `model-catalog.ts`.
- Preserve existing user-facing defaults:
- OpenAI auto → `minimal`
- OpenAI Codex auto/minimal → `low`
- Anthropic auto → `minimal`
- Anthropic thinking budgets keep the previous tuned values, including
`high: 24576`
- Keep `onPayload` available as an advanced escape hatch, but stop using
it for built-in reasoning defaults.
## Key Invariants
- Built-in reasoning-capable OpenAI, OpenAI Codex, and Anthropic models
still enable reasoning by default.
- DeepSeek/Kimi behavior is unchanged.
- OpenAI Codex still avoids unsupported `minimal` by mapping
auto/minimal to `low`.
- Anthropic older budget-based models retain the existing token budget
tuning.
- Anthropic adaptive-thinking models are delegated to pi-ai so they
receive the correct adaptive payload shape.
## Non-goals
- Does not remove the public/runtime `onPayload` hook.
- Does not change model selection or provider availability detection.
- Does not attempt to add built-in reasoning defaults for every provider
marked as reasoning-capable.
- Does not add real-provider integration tests in this PR.
## Trade-offs
The main alternative was to keep expanding catalog-level `onPayload`
rewrites for each provider-specific reasoning behavior. Delegating to
pi-ai is cleaner because pi-ai already tracks provider API details such
as OpenAI reasoning summaries and Anthropic adaptive thinking. The
trade-off is that Electric Agents now depends more directly on pi-ai’s
`reasoning` option behavior, which is already the abstraction we use for
provider streaming.
## Verification
```bash
pnpm --filter @electric-ax/agents-runtime exec vitest run test/pi-adapter.test.ts
pnpm --filter @electric-ax/agents exec vitest run test/model-catalog.test.ts
pnpm --filter @electric-ax/agents-runtime exec tsc --noEmit --pretty false
pnpm --filter @electric-ax/agents exec tsc --noEmit --pretty false
GITHUB_BASE_REF=main node scripts/check-changeset.mjs
```
All passed.
Recommended smoke coverage before merge, if provider credentials are
available:
- OpenAI reasoning model, e.g. `gpt-5`
- OpenAI Codex model
- Anthropic older budget-based thinking model
- Anthropic adaptive-thinking model such as `claude-sonnet-4-6` or Opus
4.7
## Files changed
- `.changeset/delegate-reasoning-pi-ai.md`
- Adds patch changeset coverage for `@electric-ax/agents` and
`@electric-ax/agents-runtime`.
- `packages/agents-runtime/src/types.ts`
- Adds `reasoning` and `thinkingBudgets` to `AgentConfig`.
- `packages/agents-runtime/src/context-factory.ts`
- Passes configured reasoning options into the pi adapter.
- `packages/agents-runtime/src/pi-adapter.ts`
- Forwards `reasoning` and `thinkingBudgets` into pi-ai stream calls.
- `packages/agents-runtime/test/pi-adapter.test.ts`
- Adds coverage that configured reasoning options are passed to stream
calls.
- `packages/agents/src/model-catalog.ts`
- Removes built-in provider payload rewriting via `onPayload`.
- Resolves built-in reasoning defaults into `AgentConfig.reasoning`.
- Preserves Anthropic thinking budgets for pi-ai.
- `packages/agents/test/model-catalog.test.ts`
- Updates expectations from raw payload mutation to delegated reasoning
config.
Delegate built-in reasoning configuration to pi-ai instead of rewriting provider request payloads in the model catalog. Built-in OpenAI, OpenAI Codex, and Anthropic reasoning models now pass `reasoning` through the runtime adapter, preserving existing `auto` defaults and Anthropic thinking budgets while letting pi-ai own provider-specific payload shapes.
0 commit comments