Skip to content

fix: fc mcp overstep#34

Closed
phvalguima wants to merge 21 commits intohuggingface:mainfrom
Aleph-Alpha:fix-fc-mcp-overstep
Closed

fix: fc mcp overstep#34
phvalguima wants to merge 21 commits intohuggingface:mainfrom
Aleph-Alpha:fix-fc-mcp-overstep

Conversation

@phvalguima
Copy link
Copy Markdown

Currently, the inference loop will iterate over handleOneTurnStream and finish if one of either happens: (1) the MAX value (hardcoded to 5) happens; or (2) the payload.messages.length does not grow, which means there were no MCP calls needed to be resolved and added to the payload.

That causes a problem in two cases, however:

  1. Mix of function and MCP calls is involved: if the user submits a request with both, then the first loop will return two calls - one to MCP and another for function; responses.js then will pick that up, resolve the MCP call and rerun an inference, causing partial answers
  2. Mix of MCP calls where some may be approved/not requested approvals; the rest requests approval

This PR fixes it by adding a new loop breaker: hasUserTask, which signals if there are any function/mcp calls that are demanding an user integration.

If that is true, the loop must break and return the partial answer to the user.

frac and others added 21 commits March 2, 2026 09:19
(cherry picked from commit a9f96653082321901f2967474c8d9b5cfec8b6ee)

Update package.json

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Update src/middleware/validation.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Update package.json

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

fix: adress review comments
…jects

  Move the client.chat.completions.create() call inside the existing
  try/catch/finally block so that if it rejects (e.g. auth error, network
  timeout, invalid model), the span is properly ended and the error is
  recorded. Previously the span would leak because the finally block
  never ran.

  Add regression test verifying recordException, setStatus, and end()
  are called on the span when create() rejects.
@phvalguima phvalguima closed this Mar 18, 2026
@phvalguima phvalguima deleted the fix-fc-mcp-overstep branch March 20, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants