Repository navigation
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
unsloth/studio/backend/routes/inference.py
Lines 9160 to 9162 in 5d17e42
When /api/inference/cancel sets this managed loop's cancel_event, the loop returns normally rather than raising CancelledError, so control reaches this completion branch with stream_failed=false. The API monitor is consequently finalized as a successful request and a normal terminal frame is appended, unlike the other streaming paths that inspect their cancellation event and record cancelled; this corrupts cancellation and completion metrics for externally managed tool runs. Check cancel_event.is_set() before calling the successful finish path.
ℹ️ 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".
| choice = raw_choice | ||
| delta = choice.get("delta") | ||
| if isinstance(delta, dict): | ||
| delta.pop("tool_calls", None) |
There was a problem hiding this comment.
Preserve provider metadata beyond the current request
Fresh evidence beyond the fixed immediate continuation is that this still removes the only browser-bound copy of each tool call's extra_content, while the synthesized tool_start contains only normalized name, arguments, ID, and provenance. After a Gemini, Anthropic, or OpenAI reasoning tool round completes, the frontend therefore stores the call without its thought signature, signed thinking blocks, or reasoning items; the next user message replays that historical function call without the provider-required metadata and can be rejected even though the in-process continuation succeeded. Persist the opaque continuation metadata with the stored tool call, or retain equivalent server-side history.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Rejected: the provider contracts scope strict continuation metadata to the active tool-use turn, which the managed loop already preserves in process. Google explicitly validates only the current turn after the latest ordinary user message: https://ai.google.dev/gemini-api/docs/generate-content/thought-signatures
|
Fixed the cancellation-status issue from the latest review in |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Sorry for being noise here. I am interested in using unsloth desktop to connect to my llama-swap instance, so tool calls for this external provider would be very welcomed. |
Resolve Studio-managed provider tools alongside credential persistence and upstream provider safeguards. Co-Authored-By: ForgeCode <[email protected]>
The squash merge of #8665 kept only two trailers, so the four PRs that work was built out of are not attributed anywhere in main's history. Recording them here. #8626 (@khalidejaz) contributed the registry capability and the hidden-entry exposure, down to the provider_runs_local_tools() name. #8630 (@mahiatlinux) contributed the loop internals: the user-turn append, the tool-stream advance and drain, usage merging, the approval flush delay, the budget-exhausted nudge and the streamed tool-name fix, plus a number of its test cases. They also built the merged branch and drove it in a browser against a control worktree, which found several real defects before release, including a truncated turn discarding a healed call together with the text describing it. #7805 (@Etherll) contributed the hosted-provider reach. #7330 (@Souravrajvi0) is the original OpenAI-compatible framing the work started from. Two things were deliberately not taken, and the difference is worth recording: the per-connection framing from #8630 and the studio_tool_execution column from #7805. #8665 shipped a static disclosure instead while widening the capability from four self-hosted types to thirteen. Co-authored-by: Malik Khalid Ejaz <[email protected]> Co-authored-by: Maheswar Kumar <[email protected]> Co-authored-by: Etherl <[email protected]> Co-authored-by: Souravrajvi0 <[email protected]>
) The squash merge of #8665 kept only two trailers, so the four PRs that work was built out of are not attributed anywhere in main's history. Recording them here. #8626 (@khalidejaz) contributed the registry capability and the hidden-entry exposure, down to the provider_runs_local_tools() name. #8630 (@mahiatlinux) contributed the loop internals: the user-turn append, the tool-stream advance and drain, usage merging, the approval flush delay, the budget-exhausted nudge and the streamed tool-name fix, plus a number of its test cases. They also built the merged branch and drove it in a browser against a control worktree, which found several real defects before release, including a truncated turn discarding a healed call together with the text describing it. #7805 (@Etherll) contributed the hosted-provider reach. #7330 (@Souravrajvi0) is the original OpenAI-compatible framing the work started from. Two things were deliberately not taken, and the difference is worth recording: the per-connection framing from #8630 and the studio_tool_execution column from #7805. #8665 shipped a static disclosure instead while widening the capability from four self-hosted types to thirteen. Co-authored-by: Malik Khalid Ejaz <[email protected]> Co-authored-by: Maheswar Kumar <[email protected]> Co-authored-by: Etherl <[email protected]> Co-authored-by: Souravrajvi0 <[email protected]>
Summary
Adds a per-connection
studio_tool_executionoption for external providers. It is disabled by default and lets compatible models use Studio web search, Python, terminal, and MCP tools through the existing permission and sandbox controls.Supports OpenAI-compatible endpoints, including Ollama, plus native OpenAI, Anthropic, and Gemini provider paths when the selected model supports function calling.
Motivation
External connections could use some provider-hosted tools, but they could not run Studio-managed tools. Issue #7761 specifically requests web search, MCP, and code tools for models connected through Ollama.
Changes
studio_tool_executionto provider create, update, and response models instudio/backend/models/providers.py:58.studio/backend/storage/providers_db.py:79.studio/frontend/src/features/chat/chat-providers-dialog.tsx:1124.studio/backend/core/inference/external_tool_loop.py:188.tool_start, progress, andtool_endevents to the existing chat UI.studio/backend/routes/inference.py:8984.studio/frontend/src/features/chat/api/external-tool-payload.ts:13.tool_useblocks for Anthropic instudio/backend/core/inference/external_provider.py:2050.Migration notes
The provider database is migrated automatically when Studio opens it:
Existing connections remain disabled. No manual migration or downtime is required. Downgrading leaves the additive column in place, but older versions do not use it.
Screenshots
How to test
Run the focused backend tests:
Run the frontend test and typecheck:
cd studio/frontend node --experimental-strip-types --test tests/external-studio-tools.test.ts npm run typecheckManual verification:
unsloth studio -p 8888.Related
Closes #7761