Repository navigation
Conversation
…routing, and metrics UI
…forced tool calling
…nthropic and Responses models
…ovider payload tests
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 01f6e9c5fa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| UsagePurpose.Light -> roleEffort to CallOptions.LIGHT_MAX_OUTPUT_TOKENS | ||
| else -> roleEffort to null | ||
| } | ||
| val forceToolCall = purpose == UsagePurpose.Light |
There was a problem hiding this comment.
Scope forced Light prompting to tool calls
When modelFor(ModelRole.Light) is used outside ModelCaller.routed, as AppAccessScreen.refresh does for AppClassifier and TeachRuntime.build does for Teach.draft, this sets the forced-tool flag and 200-token cap on the entire client. Those callers invoke complete with no tools, but the adapters still inject LightPrompt whenever the model flag is set, so they cannot produce the text those callers parse; app classification falls back to Main and Teach falls back to local assembly. Keep these constraints on routed tool calls rather than every Light-role model.
Useful? React with 👍 / 👎.
| val finalLight = finalAttempt?.first | ||
| val usedLight = finalAttempt?.second ?: firstAttempt?.second ?: picked | ||
| when (val v = validation) { | ||
| is LightValidation.Accepted -> return v.reply to usedLight |
There was a problem hiding this comment.
Include the first attempt's usage when a retry succeeds
When the first Light response has no tool and the retry returns an accepted tool call, this branch returns only the retry's ModelReply; unlike the rejection path below, it never includes firstLight usage. AgentLoop therefore records only the second attempt, so RunMetrics.tokens and the displayed run totals undercount the first request's billed input and output tokens, even if the separate model-call tally retains aggregate usage. Aggregate both attempts or record the first attempt separately.
Useful? React with 👍 / 👎.
| if (reply == null) { | ||
| return LightValidation.Rejected("light_error", "model_error", null) | ||
| } | ||
| val call = reply.parts.filterIsInstance<Part.ToolCall>().firstOrNull() |
There was a problem hiding this comment.
Validate the first actionable Light call
When a Light response puts the supported task_progress pseudo-call before a safe offered action, this selects the pseudo-call and the offered-name check rejects the whole response because task_progress is not a declared tool. ReplyCalls intentionally skips that pseudo-call and handles the real action, so this new validation discards an otherwise usable Light response and re-asks the step on Main. Validate the first non-progress action while leaving progress parsing to ReplyCalls.
Useful? React with 👍 / 👎.
…ge, and skip task_progress
Summary
Implements universal forced tool calling for Light-role steps across all upstream model adapters, with a 200-token Light output cap, single-line no-tool retry, permissive tool-call validation (
LightCallValidator), upfront Main routing, and Light rejection telemetry/metrics.What's included
ChatModel.kt): AddedCallOptions(LIGHT_TOOL_ONLY,LIGHT_MAX_OUTPUT_TOKENS = 200) andLightPrompt(tool-call-only system instruction + 1-line retry reminder).GeminiModel: sendstool_config.function_calling_config.mode = "ANY"andgenerationConfig.maxOutputTokenswhen forced.OpenAiCompatModel: sendstool_choice = "required"andmax_tokens(only on forced Light calls viaProviderStore), with 400/422 graceful fallback stripping unsupportedtool_choice/max_tokens.ResponsesModel: sendstool_choice = "required"andmax_output_tokens(skipped for ChatGPT plan, only on forced Light calls viaProviderStore), with 400/422 fallback.AnthropicModel: sendstool_choice = {"type": "any"}(disablingthinkingwhen forced so Anthropic accepts forced tool choice) andmax_tokens, with 400/422 fallback.ModelRouter.kt,ModelCaller.kt,LightCallValidator.kt,ConfirmDecision.kt):LightPrompt.RETRY_REMINDERif Light returns prose without a tool call.LightCallValidator(accepting valid offered non-privileged calls, auto-fillingsnapshotIdwhenrefmatches current snapshot, rejecting missing targets / invalid args / irreversible actions).RunEvent.kt,RunMetrics.kt,RunStore.kt,RunMetricsUi.kt,strings_metrics.xmlacross all 12 UI languages):reason,decisionScore,validatorReason,lightTool,lightOutputTokens, andlightRetriedonlight_rejectedreplies.Upstream adaptations
wangzan101/Mika:main(9c7aabd8).ModelPoolrouting,RateLimitGovernor,OpenAiServiceTier,keySupplier/onKeyRejectedkey rotation inGeminiModel/OpenAiCompatModel, andMeteredModel.counted(system, messages, tools).maxOutputTokensis only forwarded to Chat Completions / Responses adapters on forced Light calls (never on probes or regular Main calls).metrics_light_rejectedtovalues-tr/strings_metrics.xmlto satisfy all 12 upstream UI locales.VertexModel,Antigravity) and replaced a local file path inAgentLoopLightTestwithFile.createTempFile.How to test
Verified locally:
translations.py checkpassed (3,933 resources across 12 UI languages) and all listed:core:testsuites passed.