Skip to content

Three unverified checks on the OpenAI-compatible (BYO-key) path against a hosted provider #2189

Closed

Description

@malibio

Overview

This issue was written when no hosted provider had ever been used with the OpenAI-compatible (BYO-key) agent path. That is no longer true: the path has since been run against OpenRouter with real keys and real tool calls, for lookup and write turns, on a reasoning and a non-reasoning model (#3704, #3706). What is left is three specific checks from the original scope that nobody has done. The full original description is in this issue's edit history.

Problem Statement

  • Nothing has confirmed that an API key entered in Settings stays out of the daemon log and the prompt dumps.
  • The routing probe runs one synthetic routed turn per model load and switches off candidate injection for a model that fails it. Against a hosted provider, a rate limit or a transport error at probe time may be indistinguishable from a real "this model cannot route" verdict, which would switch routing off for a model that routes fine.
  • A play's Edit chat opens on a message the system writes, so its first turn sends system, assistant, system, user: a conversation whose first non-system message is the assistant's. That shape is verified on the native model only. A server that is strict about role order could reject it.

Documentation

  • ADR-034 - the provider modes, including OpenAI-compatible endpoints
  • ADR-056 - which models count as evidence
  • No docs change expected.

Acceptance Criteria

  • With a key entered through Settings and several turns run, the daemon log and a prompt dump are searched for the key and it is absent; if it is present, that is fixed here
  • The routing probe's verdict for one hosted model is shown to be earned: a rate-limited or failed probe request is not recorded as "cannot route", or the code is changed so it is not
  • Opening Edit on a play with an OpenAI-compatible model selected and sending the first reply works on at least one hosted provider, or the rejection is recorded and fixed
  • Anything found that is a separate defect is filed with its reproduction
  • Code passes bun run quality:fix

Technical Specifications

Reference Files

  • packages/agent/src/local_agent/openai_compat_inference.rs - the engine and its per-request logging
  • packages/agent/src/local_agent/openai_compat_prompt_dump.rs - the dump
  • packages/agent/src/local_agent/routing_probe.rs - the per-model verdict
  • packages/daemon/src/services/settings_service.rs - config storage and the probe verdict carried forward

Implementation Details

  • Use a free hosted OpenAI-compatible provider; a person creates the key and enters it in Settings. Record which provider and model were used.
  • A transport that works with weak agent behaviour is a pass for this issue; prompt quality is not in scope.

Related Issues

Non-Goals

  • The four-request walkthrough of the original description, which later work covered
  • Prompt and guidance tuning

Activity

  1. mstomar125 commented on Aug 21, 2026

    @mstomar125
    Contributor

    Picked this up but it's blocked at step 1: this issue needs a real API key from a free hosted OpenAI-compatible provider (e.g. Google AI Studio), which requires an interactive browser/account signup this environment doesn't have (standing constraint — no browser/Google account access on this remote box, deferred to local-machine sessions in prior work). Checked for an existing stored credential in ~/nodespace/.env and local NodeSpace config — none found. Leaving this on the board as Todo rather than assigning it further autonomous work; needs either a human to provision the key and hand it off, or to be picked up from a machine with browser access.

  2. malibio commented on Aug 21, 2026

    @malibio
    CollaboratorAuthor

    @mstomar125 — clarification on the blocker: create the key yourself. AI Studio keys are free and self-serve, so there is no need to wait for one to be handed over.

    No key should be passed around, and none should go into a .toml or .env — that is not the flow under test. This issue is specifically about the GUI path a user would take: open Settings, add the provider with your own key, pick that endpoint as the AI Chat model, then run the agentic requests. Entering it through Settings is part of what is being exercised, so checking ~/nodespace/.env or the daemon config was looking in the wrong place by design.

    If browser access on that box is a hard constraint, this one needs to move to a machine that has it rather than be worked around — provisioning is a normal one-time setup step here, not a credential handoff.

    Two things worth knowing before you start, both of which will otherwise look like new bugs:

    #2198 is on this exact path and is yours. "OpenAI-compat engine drops assistant tool_calls from replayed history" — any multi-turn agentic request replays history, so the model loses the record of what it just did. Worth fixing first; otherwise you will rediscover it by hand here.

    The routing probe will fire on a new served model. Stage-2 candidate injection suppresses tool-calling outright on some served models — measured on mistral:7b, where any injected block suppressed, regardless of content (#1828/#1829). A one-time probe per (base_url, model) caches the verdict and sets routing_disabled, so a Gemini endpoint may silently run with Stage-2 injection off — a different pipeline than the native path. Read the probe verdict out of the daemon log before drawing conclusions about behavior, or a routing difference will read as a model difference.

  3. malibio commented on Aug 21, 2026

    @malibio
    CollaboratorAuthor

    @mstomar125 — assigning this to you. To be explicit about scope, since "exercise it end-to-end" can be read narrowly:

    This is a test-and-fix task, not just a test task. Drive the BYO-key path through the GUI as a user would, then act on whatever it turns up:

    • Fix what is in scope — anything on the OpenAI-compat path itself (transport, auth, /models and /chat/completions dialect handling, settings persistence, model selection, the agentic turn). Fix it here.
    • File what is not — a finding that is really a separate defect, or that needs its own investigation or design decision, gets its own issue with a repro. Do not bundle unrelated fixes into this PR.
    • Record what you could not reach. If a provider quirk blocks a path, say which and why rather than leaving it silent. A negative result is a result.

    Create the AI Studio key yourself — free and self-serve. Enter it through Settings in the running app, not a .toml or .env: the settings UI is part of what is under test, so bypassing it skips the surface this issue exists to exercise. No key gets handed over or committed.

    Two known hazards on this exact path, so they read as expected rather than as new discoveries:

    #2198 is yours and sits directly under this. The OpenAI-compat engine drops assistant tool_calls from replayed history, so any multi-turn agentic request loses the record of what it just did. Worth fixing first — otherwise you will rediscover it by hand here, and it will contaminate every multi-turn result you record.

    The routing probe fires on a new served model. Per #1828/#1829, Stage-2 candidate injection suppresses tool-calling outright on some served models — measured on mistral:7b, where any injected block suppressed regardless of content. A one-time probe per (base_url, model) caches the verdict and sets routing_disabled, so a Gemini endpoint may silently run with Stage-2 injection off — a materially different pipeline from the native path. Read the probe verdict out of the daemon log before drawing conclusions, or a routing difference will look like a model difference.

    One methodological note, learned the hard way in #2188: if something looks wrong, dump the prompt before theorising about it. NODESPACE_PROMPT_DUMP=<path> captures the exact request at the chokepoint, and the OpenAI-compat path has its own capture point (openai_compat_prompt_dump.rs) writing to the same file with "engine": "openai_compat". Three hypotheses in that PR were refuted by a dump that took seconds to run.

  4. malibio commented on Aug 21, 2026

    @malibio
    CollaboratorAuthor

    Starting on this. One blocker: exercising this end-to-end requires a real API key for a free hosted OpenAI-compatible provider (Google AI Studio per the issue, or another free provider). I don't have one and can't generate one myself — I'll need it supplied (e.g. pasted into Settings → Model Manager directly by whoever has an AI Studio account, or handed to me to enter).

    Proceeding in the meantime with the startup sequence and static investigation of the two known-shaky areas (routing_probe.rs verdict logic, EXCLUDED_MODEL_FRAGMENTS in live_openai_compat_routing.rs) so I'm ready to move fast once a key is available.

  5. malibio commented on Aug 21, 2026

    @malibio
    CollaboratorAuthor

    Baseline: Frontend 4794 passed (227 test files), Duration 79.23s. Rust baseline requires a warm cargo cache — will run as part of test:all before PR.

  6. self-assigned this
    on Aug 21, 2026
  7. malibio commented on Aug 21, 2026

    @malibio
    CollaboratorAuthor

    Correction to my earlier comment: I do have a self-serve path to an AI Studio key — I misread the constraint as 'need a key handed to me' when it's actually 'create one myself, enter it through Settings.' The actual blocker is that key creation needs interactive browser/Google-account access, which I don't have as a CLI agent. I'll flag this to Michael directly rather than block silently.

    In the meantime: I'm picking up #2198 first (assistant tool_calls dropped from replayed history), since it directly contaminates any multi-turn agentic test here and per Michael's guidance above should land before the walkthrough. Will return to this issue once that's merged and a key is available.

  8. malibio commented on Aug 22, 2026

    @malibio
    CollaboratorAuthor

    @mstomar125 — OpenRouter is a second option for the free key, if AI Studio proves awkward. Either is fine; the issue only needs a real hosted OpenAI-compatible endpoint reached over the public internet.

    base_url: https://openrouter.ai/api/v1
    api_key:  <your OpenRouter key>
    model:    <one of the :free ids below>
    

    Verified against their live API today (2026-08-22): 421 models, 18 with a :free suffix, and 17 of those 18 advertise tools in supported_parameters — so tool calling, which is the entire point of this test, is available on the free tier rather than paywalled.

    A few free ids that list tool support, with their context windows:

    model ctx
    z-ai/glm-5.2:free 256k
    cohere/north-mini-code:free 256k
    thinkingmachines/inkling:free 262k
    poolside/laguna-s-2.1:free 262k
    nvidia/nemotron-3.5-lightning:free 1M
    liquid/lfm-2.5-2.6b:free 64k

    Re-check the list at GET https://openrouter.ai/api/v1/models before choosing — free-tier availability rotates, and supported_parameters is the field that tells you whether a given model will accept a tool call at all.

    Why this may be the better choice than AI Studio here: OpenRouter is a strict OpenAI-compatible implementation, which is precisely the surface this issue exists to exercise. Local Ollama accepts malformed payloads silently — that laxness is why the tool_calls serialization bug (#2198, fixed in PR #2236) survived unnoticed while every prior measurement ran against it. A strict endpoint fails loudly on a contract violation, which is the signal we want.

    Being able to swap model across several providers behind one key and one base_url is also useful for the routing-probe concern noted above: if one served model comes back routing_disabled you can try another without reconfiguring anything, and record the verdict per model.

    Whichever you pick, record which provider and model you used and why — the result is not portable across endpoints, so the next person needs to know what was actually exercised.

    Still applies: create the key yourself, enter it through Settings in the running app, no key in a .toml, .env, or committed anywhere.

  9. mstomar125 commented on Sep 14, 2026

    @mstomar125
    Contributor

    Moved to Backlog — deprioritized for now, not being worked right now. Still needs a real OpenRouter or Google AI Studio key (account creation isn't something an agent can self-serve) before the end-to-end agentic test can run. Instructions and free model recommendations are already in this thread, ready to go whenever this comes back up.

  10. removed their assignment
    on Sep 28, 2026
  11. malibio commented on Oct 5, 2026

    @malibio
    CollaboratorAuthor

    One more case for this pass, from the pinned-chat work (PR #3575): a play's Edit chat opens on a message the system writes, so its first turn sends the model system, assistant, system, user: a conversation whose first non-system message is the assistant's. That shape is verified on the native Gemma 4 E4B template (nlp-engine tests/it/assistant_first_conversation.rs) and has not been tried against an OpenAI-compatible endpoint, where a server strict about role order could reject it. To check: open Edit on a play with an OpenAI-compatible model selected and send the first reply.

  12. removed their assignment
    on Oct 11, 2026
  13. changed the title [-]Exercise the OpenAI-compatible (BYO-key) agent end-to-end against a free hosted provider, and fix what breaks[/-] [+]Three unverified checks on the OpenAI-compatible (BYO-key) path against a hosted provider[/+] on Oct 11, 2026
  14. malibio commented on Oct 11, 2026

    @malibio
    CollaboratorAuthor

    Trimmed and unassigned. Most of the original scope was overtaken by the hosted-provider runs in #3704 and #3706. Three checks remain and are now the whole issue: the key stays out of logs and dumps, the routing probe's verdict is earned and not a rate-limit artifact, and an assistant-first conversation works on a hosted provider.

  15. malibio commented on Oct 11, 2026

    @malibio
    CollaboratorAuthor

    Closing. Two of the three remaining checks are verified, 2026-10-11:

    1. The key stays out of logs and dumps. The stored key was searched for in the daemon logs and agent session files of a machine with real hosted-provider traffic: zero occurrences, and no authorization or bearer lines. The prompt dump writes the request's messages only and never reads the key or the headers.
    2. The routing probe's verdict is earned. An engine error or a timeout is returned as an error and never recorded as a verdict (probe_routing_ok, with the unit test an_engine_error_is_not_a_suppression_verdict). Seen for real on 2026-10-08: the provider answered 429, the probe timed out after 60s, and the daemon logged "routing probe failed to complete; leaving routing enabled for this load".
    3. An assistant-first conversation on a hosted provider was not tried. It is carried as one verification step on A play's Edit chat: describe the play first, let the user ask about it, and route a reply with the message it answers #3738, which fixes the play Edit chat's first reply and has to land first for the case to be reachable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions