Commit graph

399 commits

Author SHA1 Message Date
Mario Zechner
693112e395 feat(ai): add originator option to loginOpenAICodex 2026-01-20 01:28:51 +01:00
Mario Zechner
d2be6486a4 feat(ai): add headers option to StreamOptions for custom HTTP headers
- Added headers field to base StreamOptions interface
- Updated all providers to merge options.headers with defaults
- Forward headers and onPayload through streamSimple/completeSimple
- Bedrock not supported (uses AWS SDK auth)
2026-01-20 01:08:31 +01:00
Mario Zechner
2b04aefa6d feat(ai): add AWS ECS/IRSA credential detection for Bedrock, fixes #848
Added support for additional AWS credential environment variables:
- AWS_CONTAINER_CREDENTIALS_RELATIVE_URI (ECS task roles)
- AWS_CONTAINER_CREDENTIALS_FULL_URI (ECS task roles)
- AWS_WEB_IDENTITY_TOKEN_FILE (IRSA for Kubernetes)

Also fixed undefined currentModel variable in OAuth error handling.
2026-01-19 16:10:10 +01:00
Mario Zechner
2d27a2c728 fix(ai): skip errored/aborted assistant messages in transform-messages
Fixes OpenAI Responses 400 error 'reasoning without following item' by
skipping errored/aborted assistant messages entirely rather than filtering
at the provider level. This covers openai-responses, openai-codex-responses,
and future providers.

Removes strictResponsesPairing compat option (no longer needed).

Closes #838
2026-01-19 15:55:29 +01:00
Mario Zechner
0e5977ad39 Add [Unreleased] section for next cycle 2026-01-19 00:23:57 +01:00
Mario Zechner
2c7c23b865 fix(ai): normalize tool call ids and handoff tests fixes #821 2026-01-19 00:10:49 +01:00
Mario Zechner
d43930c818 feat(ai): add strictResponsesPairing for Azure OpenAI Responses API
Split OpenAICompat into OpenAICompletionsCompat and OpenAIResponsesCompat
for type-safe API-specific compat settings. Added strictResponsesPairing
option to suppress orphaned reasoning/tool calls on incomplete turns,
fixing 400 errors on Azure's Responses API which requires strict pairing.

Closes #768
2026-01-18 20:15:33 +01:00
Mario Zechner
632495338f Add [Unreleased] section for next cycle 2026-01-17 22:02:59 +01:00
Mario Zechner
4068bc556a chore: simplify codex prompt handling 2026-01-17 21:53:01 +01:00
Mario Zechner
a5f1016da2 fix(ai): normalize tool names case-insensitively against CC tool list
- Replace hardcoded pi->CC tool mappings with single CC tool name list
- Case-insensitive lookup: if tool name matches CC tool, use CC casing
- Remove broken find->Glob mapping (round-trip failed)
- Add test coverage for tool name normalization
2026-01-17 21:03:47 +01:00
Mario Zechner
0f3a0f78bc fix(ai): prevent orphaned tool results after errored assistant messages
When an assistant message has stopReason 'error', its tool calls are now
excluded from pending tool tracking. This prevents synthetic tool results
from being generated for calls that will be dropped by provider-specific
converters (e.g., Codex drops tool calls from errored messages).

Previously, this mismatch caused OpenAI to reject requests with 'No tool
call found for function call output with call_id ...' errors.

fixes #812
2026-01-17 20:20:39 +01:00
Pablo Tovar
cd43b8a9ca
fix: ensure max_tokens > thinking.budget_tokens for bedrock claude (#797)
Bedrock Claude models require max_tokens to exceed thinking.budget_tokens.
This constraint was handled for anthropic-messages API but missing for
bedrock-converse-stream, causing compaction failures.

Extracted adjustMaxTokensForThinking() helper that:
- Adds thinking budget on top of desired output tokens
- Reduces thinking budget if insufficient room (min 1024 output tokens)
- Applied to both anthropic-messages and bedrock-converse-stream APIs
2026-01-17 10:55:30 +01:00
Mario Zechner
7f9cf543d5 Add [Unreleased] section for next cycle 2026-01-17 00:32:57 +01:00
Mario Zechner
5d3e7d5aaa fix(ai): preserve unsigned tool call context for Gemini 3 with anti-mimicry note
Instead of skipping unsigned tool calls entirely (which lobotomizes context),
convert them to text with an explicit note telling the model this is historical
context from a different model and not a format to mimic.

This preserves tool call/result context when switching from providers without
thought signatures (e.g. Claude via Antigravity) to Gemini 3.
2026-01-16 23:42:39 +01:00
Mario Zechner
fbb74bb29e fix(ai): filter empty error assistant messages in transformMessages
When 429/500 errors occur during tool execution, empty assistant messages
with stopReason='error' get persisted. These break the tool_use -> tool_result
chain for Claude/Gemini APIs.

Added centralized filtering in transformMessages to skip assistant messages
with empty content and no tool calls. Provider-level filters remain for
defense-in-depth.
2026-01-16 22:35:50 +01:00
Mario Zechner
ffdc8d686b docs: add OpenCode Zen to provider lists in coding-agent README 2026-01-16 21:20:52 +01:00
Danila Poyarkov
923b9cb9ee
fix(ai): coerce string numbers in tool argument validation (#786)
* fix(ai): coerce string numbers in tool argument validation

* fix(ai): clone tool arguments before AJV validation for type coercion
2026-01-16 20:16:13 +01:00
Pablo Tovar
ba8059a502
fix: sanitize bedrock tool call ids (#781) 2026-01-16 17:51:48 +01:00
Mario Zechner
f900eb591d Fix provider feature detection to use model.provider, not just URL
Previously, OpenAI-compatible provider settings (like developer role support)
were detected only from the baseUrl. When using custom URLs (e.g., proxies),
detection failed. Now checks model.provider first, then falls back to URL.

Fixes #774
2026-01-16 12:41:23 +01:00
Mario Zechner
356a482527 fix(tui): add vertical scrolling to Editor when content exceeds terminal height
The Editor component now accepts TUI as the first constructor parameter,
enabling it to query terminal dimensions. When content exceeds available
height, the editor scrolls vertically keeping the cursor visible.

Features:
- Max editor height is 30% of terminal rows (minimum 5 lines)
- Page Up/Down keys scroll by page size
- Scroll indicators show lines above/below: ─── ↑ 5 more ───

Breaking change: Editor constructor signature changed from
  new Editor(theme)
to
  new Editor(tui, theme)

fixes #732
2026-01-16 04:12:21 +01:00
Mario Zechner
c08801e4c5 Add retry logic to OpenAI Codex provider
Fixes #733
2026-01-16 03:15:59 +01:00
Mario Zechner
be26d362fa Fix alt+backspace in Kitty mode and clamp Codex effort (refs #752) 2026-01-16 01:30:46 +01:00
Mario Zechner
6484ae279d
Finalize OpenAI Codex compatibility (#737)
- align Codex Responses provider with Pi static instructions
- simplify Codex request/stream handling and cleanup exports
- keep legacy OpenCode Codex prompt for testing until Pi prompt is allowlisted
2026-01-16 00:58:36 +01:00
Melih Mucuk
cceb5908d9
fix: opencode provider uses system role instead of developer (#755)
* fix: opencode provider uses system role instead of developer for /v1 endpoint

* changelog updated
2026-01-15 21:26:31 +01:00
Mario Zechner
e46cc55fe0 Add [Unreleased] section for next cycle 2026-01-15 17:36:40 +01:00
Roshan Singh
b18f401d9e
fix(ai): avoid unsigned Gemini 3 tool calls (#741) 2026-01-15 13:12:39 +01:00
Aadish Verma
cd83e73845
feat: add gpt-5.2-codex models for copilot & zen (#734) 2026-01-15 03:24:20 +01:00
Mario Zechner
cc8c51d9ae chore(ai): regenerate models 2026-01-14 22:25:21 +01:00
Mario Zechner
0a7537bf86 Revert "feat(ai): add gpt-5.2-codex to OpenAI provider (#730)"
This reverts commit 5a795b9857.
2026-01-14 22:22:55 +01:00
Anton
5a795b9857
feat(ai): add gpt-5.2-codex to OpenAI provider (#730)
* feat(ai): add gpt-5.2-codex to OpenAI provider

* fix(ai): avoid build break when model generation misses providers
2026-01-14 22:21:01 +01:00
Burak Varlı
9a438465eb
fix(ai): signature support for non-Anthropic models in Amazon Bedrock provider (#727)
* Add Amazon Bedrock models test suite for agent package

Tests basic prompts, multi-turn conversations with thinking, and
synthetic thinking signatures across all Bedrock models.

Known issues are categorized and skipped:
- Models requiring inference profile (5)
- Invalid model IDs for us-east-1 region (6)
- Max tokens config exceeds model limit (2)
- No signature support in reasoningContent (10)
- Rejects reasoning content in user messages (25)
- Validates signature format - Anthropic newer models (7)

* Fix Bedrock signature support for non-Anthropic models

Only include the signature field in reasoningContent.reasoningText for
Anthropic Claude models. Other models (OpenAI, Qwen, Minimax, Moonshot,
etc.) reject this field with:
"This model doesn't support the reasoningContent.reasoningText.signature field"

This fix enables multi-turn conversations with thinking content for
10 additional Bedrock models that previously failed.

https://buildwithpi.ai/session?7e39c05f66ea358da3f993c267fe3e29

* Add a CHANGELOG entry
2026-01-14 19:21:35 +01:00
Jian Zhang
558a77b45f
feat(ai): add support for MiniMax China (minimax-cn) provider (#725)
Co-authored-by: Jian Zhang <jzhang@yanhuangdata.com>
2026-01-14 15:41:47 +01:00
Markus Ylisiurunen
653025e6ca
Fix OpenAI responses timeout option (#706) 2026-01-14 00:07:11 +01:00
Pablo Tovar
b74535dc85
fix: apply message transforms for bedrock tool calls (#707)
Ensure Bedrock uses transformMessages before conversion.
2026-01-14 00:05:47 +01:00
Mario Zechner
2b75948c2e fix(ai): export parseStreamingJson from main package for tsx compatibility 2026-01-13 22:08:19 +01:00
Mario Zechner
09d409cc92 Fix z.ai thinking/reasoning params, fixes #688
Z.ai uses thinking: { type: "enabled" | "disabled" } instead of
OpenAI's reasoning_effort. Added thinkingFormat compat flag to handle
this. Thinking is now explicitly enabled/disabled based on user setting.
2026-01-13 18:34:07 +01:00
Markus Ylisiurunen
00ba005e50
set the prompt cache key to session id (#698) 2026-01-13 18:29:36 +01:00
Mario Zechner
28072cb31f Add more models to stream.test.ts for Vercel, set infinite timeout on OpenAI responses, closes #690 2026-01-13 17:08:56 +01:00
Timo Lins
dd263f3c24 Update model list 2026-01-13 16:42:34 +01:00
Timo Lins
65eb738c90 Rename to vercel-ai-gateway for clarity 2026-01-13 16:42:34 +01:00
Timo Lins
9860ee86f3 Change to Anthropic compatible API
It seemed as if the OpenAI message spec tried to send non-compliant messages with { text: "" } instead of { contet: "" }, which the AI Gateway did not accept.
2026-01-13 16:42:34 +01:00
Timo Lins
164a69a601 Add Vercel AI Gateway support 2026-01-13 16:42:34 +01:00
Markus Ylisiurunen
922b0a4668
add eu cross-region inference model ids for anthropic models (#685) 2026-01-13 13:02:27 +01:00
Mario Zechner
3c60ffa677 Fix tool call ID normalization for cross-provider switches to Anthropic/GitHub Copilot 2026-01-13 04:07:10 +01:00
Mario Zechner
8af8d0d672 Add MiniMax provider support (#656 by @dannote)
- Add minimax to KnownProvider and Api types
- Add MINIMAX_API_KEY to getEnvApiKey()
- Generate MiniMax-M2 and MiniMax-M2.1 models
- Add context overflow detection pattern
- Add tests to all required test files
- Update README and CHANGELOG with attribution

Also fixes:
- Bedrock duplicate toolResult ID when content has multiple blocks
- Sandbox extension unused parameter lint warning
2026-01-13 02:27:09 +01:00
Ahmed Kamal
ff15414258
Improve Gemini CLI provider retries and headers (#670)
Improve Gemini CLI provider retries and headers

- Add Antigravity endpoint fallback (tries daily sandbox then prod when baseUrl is unset)
- Parse retry delays from headers (Retry-After, x-ratelimit-reset, x-ratelimit-reset-after) before body parsing
- Derive stable sessionId from first user message for cache affinity
- Retry empty SSE streams with backoff without duplicate start/done events
- Add anthropic-beta header for Claude thinking models only
2026-01-13 01:04:53 +01:00
Danila Poyarkov
9e4ae98358
Improve Google Cloud Code Assist error handling (#665)
* Improve Cloud Code Assist error messages

- Extract just the message from verbose JSON error responses
- Extract cause from generic 'fetch failed' errors for better diagnostics

* Make 'other side closed' network error retryable

* Make 'other side closed' network error retryable
2026-01-13 00:41:20 +01:00
Mario Zechner
d442bbcc19 feat(ai): Add prompt caching for Claude models on Bedrock
Adds cache points to system prompt and last user message for:
- Claude 3.5 Haiku
- Claude 3.7 Sonnet
- Claude 4.x models (Opus, Sonnet, Haiku)

Uses Bedrock's cachePoint blocks with 5-minute TTL.
2026-01-13 00:38:12 +01:00
Mario Zechner
fd268479a4 feat(ai): Add Amazon Bedrock provider (#494)
Adds support for Amazon Bedrock with Claude models including:
- Full streaming support via Converse API
- Reasoning/thinking support for Claude models
- Cross-region inference model ID handling
- Multiple AWS credential sources (profile, IAM keys, API keys)
- Image support in messages and tool results
- Unicode surrogate sanitization

Also adds 'Adding a New Provider' documentation to AGENTS.md and README.

Co-authored-by: nickchan2 <nickchan2@users.noreply.github.com>
2026-01-13 00:32:59 +01:00
Markus Ylisiurunen
4f216d318f
Apply service tier pricing (#675) 2026-01-12 23:56:51 +01:00