fix(build-agent): validate harness/provider pairing, ask connection mode upfront#11
fix(build-agent): validate harness/provider pairing, ask connection mode upfront#11bekossy wants to merge 2 commits into
Conversation
…on.mode choice Simple no-tool agents were coming out with no Model & Harness resolved in the Agenta UI (reproduced 4x while QA-testing against a self-hosted instance). Root cause: the stored config paired harness.kind="claude" (Claude Code harness, Anthropic-only) with llm.provider="openai"/model="gpt-4o-mini". This combination is accepted by the create/commit endpoints with no server-side error, but never resolves to a working Model & Harness, so the agent looks "created successfully" and then silently does nothing. create-agent.sh and update-agent.sh now validate this pairing (and, for creation, that the full boilerplate is present) before calling the API, refusing with a specific fix message instead of creating a broken agent. SKILL.md and config-schema.md now explain the coupling explicitly, since it isn't a "fewest calls" simplification a caller should improvise on. Also addresses review feedback on the credentials setup flow: the skill now explicitly asks the user which llm.connection.mode they want (self_managed, bring your own provider key, vs agenta, use the project's own managed key) instead of silently assuming self_managed. harness.kind="claude" still requires llm.provider="anthropic" either way; connection.mode is orthogonal to that coupling.
| this block you actually choose: `self_managed` (the user's own provider API key — the | ||
| default written above) or `agenta` (the project's own managed/subscription key, no separate | ||
| provider key needed). Ask the user which they want during credentials setup (`SKILL.md`); | ||
| don't assume `self_managed` for a cloud user without asking. |
There was a problem hiding this comment.
this is wrong. @bekossy you need to explain the meaning of self-managed to the model. it always makes this mistake. self-managed means the runner is using subscription claude code / codex. which means no need to configure the api key. In cloud you can't use self-managed at all. only agenta managed (meaning the user provide their api keys in agenta and they are used)
There was a problem hiding this comment.
You're right, I had it backwards. Fixed in config-schema.md and SKILL.md: self_managed means the runner itself is logged into its own Claude Code / Codex subscription, so Agenta needs no provider API key at all. agenta means the user's provider key lives in Agenta's vault and Agenta uses it on every call. Also added the point that self_managed isn't available on cloud at all since cloud runners have no subscription of their own, so cloud always means agenta. Added a setup transcript to the PR description showing the corrected flow, and resolved the merge conflicts from #12/#14.
Resolves conflicts from #12 (trigger revision pinning) and #14 (trigger discovery descriptions), both already merged to main. Also fixes a factual error caught in review: self_managed does NOT mean "the user brings their own provider API key" and agenta does NOT mean "use Agenta's own managed/subscription key" - that was backwards. self_managed means the runner itself is logged into its own Claude Code / Codex subscription (Claude Pro/Max, ChatGPT Plus); Agenta needs no provider API key at all in that case. agenta means the user's provider API key lives in Agenta's project vault and Agenta uses it on every call. Critically, self_managed is not available on Agenta cloud at all (cloud runners have no subscription of their own), so cloud always means agenta. SKILL.md and config-schema.md corrected accordingly.
|
Addressed both:
Ready for another look. |
Context
When you build a simple, no-tool Agenta agent through this skill, the Agenta UI's Model & Harness sometimes never resolves (shows "Select a provider", nothing selected), even though creation reports success. Reproduced 4 times during QA testing against a self-hosted instance, across two coding agents.
Root cause: the coding agent occasionally wrote a config that paired
harness.kind: "claude"(the Claude Code harness, which only runs Anthropic models) withllm.provider: "openai"and a raw model id. The create and commit endpoints accept this mismatch with no error, but the agent never resolves to a working Model & Harness and never runs correctly.Changes
lib.shgets two new checks:validate_agent_config(full check, used bycreate-agent.sh) andvalidate_agent_config_delta(lighter check, tolerant of a partialupdate-agent.shdelta). Both refuse a config whereharness.kindis"claude"andllm.provideris anything other than"anthropic".Before, this config was accepted silently:
{"harness": {"kind": "claude"}, "llm": {"provider": "openai", "model": "gpt-4o-mini"}}After,
create-agent.shandupdate-agent.shreject it before making any API call, with a message explaining the coupling and how to fix it.Also, per review feedback on the credentials setup flow: the skill previously always wrote
llm.connection.modeas"self_managed"without asking. It now explicitly asks the user which mode they want at setup,self_managed(bring your own provider key) oragenta(use the project's own managed key), and only asks for a provider key in theself_managedcase. This is orthogonal to the harness/provider coupling above; both connection modes still requirellm.provider: "anthropic"whenharness.kindis"claude".SKILL.mdandconfig-schema.mdnow explain the coupling explicitly, since it is not one of the "fewest calls" simplifications a caller should improvise on.Tests
No existing test harness for the shell scripts in this repo, so verified end to end against a live self-hosted instance:
harness=claude,provider=openai) is rejected client-side bycreate-agent.sh. No API call is made, exit 1 with the new error message.harness=claude,provider=anthropic,connection.mode=agentapasses validation (confirms the new connection mode does not get flagged as a mismatch).update-agent.shwith a partial delta (onlyinstructions) still succeeds, confirming the lighter delta check does not over-reject legitimate partial updates.bash -nsyntax checks.One documented limitation, called out in
lib.sh's comment:validate_agent_config_deltaonly catches a harness/provider mismatch when both fields are present together in the delta itself. A delta that changes onlyllm.provider(relying on merge to keep a previousharness.kind: "claude") will not be caught.update-agent.sh's own guidance is to always pass the complete config, which avoids this gap.What to QA
llm.connection.modeyou want, not just silently assumeself_managed.create-agent.shshould refuse with the CONFIG ERROR message rather than creating a broken agent.Independent of the trigger-revision-pinning PR (different scripts; only a shared
SKILL.md/lib.shedit in a different location of each file). Should merge cleanly in either order, or with a trivial rebase.Closes #3.