Skip to content

xAI Grok OAuth: response tool_args not matching stock contract → unbounded RepairableException loop #1824

Description

@natearizona

Summary

Agent Zero v2.9 includes native xAI Grok OAuth (xai_grok_oauth, provider at plugins/_oauth/helpers/providers/xai_grok.py). Authentication and model routing work.

However, at least one Grok response tool-call shape is not normalized into the stock ResponseTool contract (text / message must be a non-empty string). Stock A0 raises RepairableException and the monologue repair loop can become unbounded, burning tokens and leaving the run active.

This is not "Grok unsupported." OAuth is present and connected. The defect is downstream of auth: tool arg shape × strict ResponseTool × unbounded repair retries.

Please do not ask operators to re-burn tokens reproducing this. One clean failure class is enough; evidence is held locally (redacted).

Related reliability class: open-ended monologue/tool-loop risk (see also #1088).


Environment (stock)

Item Value
Commit baadd0dd0b09fa769a1027c183b964be85d5c8cc
Runtime Official agent0ai/agent-zero image @ that commit
Local core patches None (stock tools/response.py)
Chat xai_grok_oauth / grok-4.3
Utility xai_grok_oauth / grok-code-fast-1
Embedding huggingface / sentence-transformers/all-MiniLM-L6-v2
OAuth Connected (access + refresh + id_token present)

Stock contract that rejects Grok's call

# tools/response.py @ baadd0dd
async def execute(self, **kwargs):
    for key in ("text", "message"):
        message = self.args.get(key)
        if isinstance(message, str) and message.strip():
            return Response(message=message, break_loop=True)
    raise RepairableException(
        "response tool requires a non-empty top-level text or message string argument"
    )

Call chain observed in UI tracebacks:

agent.py monologue → process_llm_result_tools → _execute_tool_request
  → plugins/_goal/tools/response.py → tools/response.py
RepairableException: response tool requires a non-empty top-level text or message string argument

Example malformed tool_args shape observed in logs

Grok emitted a structure equivalent to nesting non-string content under text (object, not plain string), e.g. conceptually:

{
  "tool_name": "response",
  "tool_args": {
    "text": {
      "user_message": "...",
      "break_loop": true,
      "attachments": []
    }
  }
}

Stock code requires tool_args.text (or message) to be a string. Nested objects fail isinstance(message, str) and raise RepairableException forever if the model does not converge.


Two surface symptoms (same defect)

1) Web UI (minimal repro / definitive)

  • Ordinary short chat in the stock Web UI (Telegram not required).
  • Grok produces valid answer content that appears in the UI.
  • Then the run hits RepairableException on the response tool and repeats (GEN/END / traceback cycles).
  • Operator sees alternating normal prose + full stack traces for the same question.

2) Telegram (user-facing impact)

  • Same underlying response tool failure with native Grok OAuth.
  • Manifests as endless typing, queued/garbled delivery, and/or a run that stays active.
  • Telegram /pause does not reliably terminate the underlying monologue/inference loop.
  • /stop is not exposed on the Telegram command surface used here.

Minimal repro (high level only — do not re-run for "more proof")

  1. Agent Zero v2.9 at baadd0dd (unmodified core).
  2. Connect native xAI Grok OAuth; Default preset Main/Utility → xai_grok_oauth models above.
  3. Web UI: new chat → short user message (e.g. a simple question).
  4. Observe: answer text may appear, then repeated RepairableException on response tool / unbounded monologue steps.

Telegram is optional for maintainers; it is the same defect with worse operator control.


Expected

  1. Grok tool-calls for response are accepted (normalize common shapes) or fail closed once with a clear error.
  2. RepairableException for response-arg shape errors is bounded (max attempts), not an infinite token sink.
  3. Channel stop controls (Web UI + Telegram /pause or equivalent) kill the active agent run and stop provider inference promptly.

Actual

  1. Valid-looking content can appear, then the final response tool rejects Grok's arg shape.
  2. Repair retries loop without bound → token burn + stuck run.
  3. Telegram impact: endless typing / queued messages; /pause insufficient.

What this is not

  • Missing xAI provider / OAuth implementation (provider, config, and tests exist at this commit).
  • API-key masquerade or third-party inference shim.
  • A local fork of tools/response.py (reproduced on stock code).
  • "Telegram-only" (Web UI alone is enough).

Requests to maintainers

  1. Normalize Grok response tool_args into the stock string contract or document/enforce the exact schema Grok is prompted to emit.
  2. Cap repair retries for response-tool shape failures (fail closed).
  3. Harden stop/pause so channel controls always terminate the monologue and stop xAI calls.
  4. Optional: log the raw tool_args (truncated) when RepairableException fires to speed future provider debugging.

Happy to supply redacted logs / UI screenshots privately if useful. We are not applying local core patches; tracking this as an upstream integration edge on the new native Grok path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions