Kiro backend does not support Anthropic prompt cache protocol.
The local cache tracker simulates cache hits/creation for Claude Code
compatibility, but subtracting those values from input_tokens caused
the reported input_tokens to drop to single digits.
input_tokens now reflects the real value; cache_creation_input_tokens
and cache_read_input_tokens are still reported for protocol compliance.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Upstream sometimes accepts a request (HTTP 200 headers) but stalls without
sending any event-stream packet. Add a configurable timeout that counts
from request dispatch until the first AWS event-stream prelude is read,
and retry on the same endpoint before falling back.
- Config: FirstByteTimeoutSec (default 10s, 0=disabled, range 0-300),
FirstByteRetries (default 1, range 0-10), with Get/Update helpers.
- kiro.go: parseEventStream signature gains onFirstByte callback, fired
once when the first 12-byte prelude reads successfully. CallKiroAPI
wraps each attempt in a context.WithCancel + time.AfterFunc timer that
cancels the HTTP request if no event arrives before the deadline.
Separate retry budgets for INVALID_MODEL_ID and first-byte timeout,
tracked on the same attempt loop; maxAttempts = max(both)+1.
- handler.go: /admin/api/general extended to read/write the two new
fields with validation (timeout 0-300, retries 0-10).
- web/index.html: General Settings card gains two numeric inputs plus
CN/EN i18n and the corresponding load/save JS.
Brought in 9 upstream commits:
- 221348b thinking routing: ClaudeRequest.Thinking + Signature + includeEmptyThinkingBlock
- 0203357 + 31aa6aa accurate input_tokens via contextUsageEvent
- 404e242 + 50f1a7e outbound proxy (socks5/http) + UI
- 940dc78 version bump to 1.0.6
- 3 CI workflow changes
Strategy: took upstream base for the 4 conflicting files, then re-applied
our local changes on top:
- config.go: InvalidModelRetries field + GetInvalidModelRetries/UpdateInvalidModelRetries
- kiro.go: AmazonQ origin CLI->AI_EDITOR, attempt-level retry loop for
INVALID_MODEL_ID, detailed log.Printf (account/model/attempt/elapsed),
log import; adopted upstream's kiroHttpStore atomic pointer for Do()
- handler.go: /admin/api/general GET/POST + apiGetGeneralConfig +
apiUpdateGeneralConfig
- web/index.html: General Settings card (invalid-model-retries),
CN/EN i18n, loadGeneralConfig/saveGeneralConfig, call from initSettings
Build + full test suite green on Go 1.24.3.
- Config: new InvalidModelRetries field (default 3, range 0-20)
- Admin API: /admin/api/general GET/POST for general settings
- Admin UI: new "通用设置" card with retry count input
- CallKiroAPI: same-endpoint retry on HTTP 400 INVALID_MODEL_ID
before falling back to next endpoint
- CallKiroAPI: switched to log.Printf with timestamp, account,
model, attempt counter, elapsed time, error body truncation
* feat: Add validation and account management functionality
- Add validation for clientID and clientSecret in refreshOIDCToken function
- Add weight field for load balancing priority in Account struct
- Implement weighted轮询策略以根据账号权重分配选择概率。
- Add batch account management functionality including enabling, disabling, refreshing, and retrieving account details.
- Update Kiro API version and adjust user agent strings to reflect new version numbers.
- Update Kiro version and modify user agent strings and header settings.
- Refactor model mapping to an ordered list for precise key matching.
- Add account bulk actions and filtering toolbar to index.html
* feat: Add logic to skip accounts with exhausted usage limits
- Add logic to skip accounts with exhausted usage limits when selecting the next account.
* fix: stabilize multimodal image compatibility across OpenCode flows
Advertise vision-capable metadata in /v1/models and make model matching deterministic so OpenCode does not downgrade image support or route 4.6 models incorrectly. Expand request translation to accept OpenCode/OpenAI attachment shapes, sanitize [Image N] placeholders safely, keep image-only follow-up turns non-empty, and improve token accounting so base64 image bytes no longer inflate prompt token usage and trigger premature compaction.
* fix: deduplicate thinking streams and trim injected prompt noise
* fix: align /v1/messages thinking blocks and message_start usage
* fix: reduce repetitive thinking across tool turns
Select a single reasoning stream source, prevent chunk replay, and preserve structured tool-loop context so the model keeps continuity instead of re-planning each turn.
* fix: unify token counting on existing API endpoints
Compute usage deterministically on /v1/messages and /v1/chat/completions even when upstream omits tokenUsage.
- remove roo-only token path and keep behavior on existing endpoints
- add proxy/token_estimator.go with shared Claude/OpenAI estimators (input/system/messages/tools + output/thinking/tool calls)
- wire stream/non-stream handlers to use estimator-derived input/output usage
- update /v1/messages/count_tokens to reuse the same estimator
- keep robust upstream usage parsing/normalization in proxy/kiro.go while dropping parser-level estimate fallback
Why: direct upstream tests show metering/context events frequently arrive without tokenUsage in this environment; this made usage zero or inconsistent. Local deterministic accounting keeps reported usage stable and explicit.
- Add claude-sonnet-4.6 (dot and dash variants) to modelMap in translator.go
- Add claude-sonnet-4.6 and claude-opus-4.6 (plus -thinking variants) to the
static fallback model list in handler.go
- Realign existing opus-4.6 entries for consistency
* feat: Add JSON copy functionality with success animation
- Add functionality to copy account data as JSON and show success animation.
* feat: Add endpoints for account details and error handling
- Add endpoint to retrieve full account details including sensitive information
- Add error handling for fetching and copying full account JSON data
- Add ban status and reason fields to account configuration
- Add account ban status and details handling in API refresh account function.
- Add logic to handle account suspension and authentication errors, updating ban status accordingly.
- Add and style badge classes for different account statuses and modify account status display logic.
- Multi-account pool with round-robin load balancing
- Auto token refresh for IAM IdC and Social auth
- Streaming support (SSE)
- Web admin panel with account management
- Docker support with GitHub Actions CI/CD
- Machine ID management per account
- Usage tracking (requests, tokens, credits)