Skip to content

fix(gateway): declare the dev agent required by the gateway e2e session key#99520

Merged
steipete merged 1 commit into
openclaw:mainfrom
masatohoshino:fix/gateway-e2e-dev-agent-fixture
Jul 3, 2026
Merged

fix(gateway): declare the dev agent required by the gateway e2e session key#99520
steipete merged 1 commit into
openclaw:mainfrom
masatohoshino:fix/gateway-e2e-dev-agent-fixture

Conversation

@masatohoshino

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #99513.

The clean-checkout e2e test src/gateway/gateway.test.ts > gateway e2e > accepts a gateway agent request over ws and returns a run id fails on current main:

GatewayClientRequestError: Agent "dev" no longer exists in configuration

Because it reproduces on an untouched checkout, it blocks contributors' local pre-push gates (pnpm check:changed and precheck flows that run the gateway lane) regardless of what they changed.

Why This Change Was Made

The failure is a broken test fixture, not a product bug: the test requests sessionKey = "agent:dev:mock-openai", but its gateway config declares only agents.defaults — no agents.list entry with id dev — so the gateway's deleted-agent guard correctly rejects the run. The sibling test in the same file declares agents.list: [{ id: "main", default: true, ... }] and passes.

The smallest repair is to declare the agent the test's own session key requires:

agents: {
  defaults: { ... },
  list: [{ id: "dev", default: true }],
},

Declaring dev (rather than switching the session key to main) preserves the tested session identity; default: true is unambiguous in a single-agent test config. The config object is local to this one test, so no other case relies on the previous shape.

Note: this is a fixture repair that restores the test's intent — it does not weaken or bypass the deleted-agent validation (the guard behaves correctly and stays untouched). #98686 previously attempted a broader fix for scheduled live/e2e failures in this area but was closed unmerged with no public discussion; this PR takes only the single-fixture slice with a fresh reproduction on current main.

User Impact

pnpm test src/gateway/gateway.test.ts passes on a clean checkout again, so contributor pre-push gates and the gateway e2e lane stop failing on an upstream fixture bug. No runtime behavior changes.

Evidence

HEAD: 9addbdeb73ceff8bd912e7ed491d7745f8cb9b1d (base upstream/main 0cc9927577)

Before (clean main, reproduced at 776b34a4e642, df350e6720, 8d535fb039 — details in #99513):

 ❯ src/gateway/gateway.test.ts (4 tests | 1 failed)
     × accepts a gateway agent request over ws and returns a run id
GatewayClientRequestError: Agent "dev" no longer exists in configuration

After (this branch):

node scripts/run-vitest.mjs src/gateway/gateway.test.ts
 Test Files  1 passed (1)
      Tests  4 passed (4)

OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 pnpm check:changed -- src/gateway/gateway.test.ts exit 0; git diff --check clean.

Non-scope: no runtime gateway behavior change; no change to deleted-agent validation; no gateway-models.profiles.live.test.ts changes (not reproduced on current main, deliberately excluded).


🤖 AI-assisted (Claude Fable 5 + Codex GPT-5.5 review). The failure, root cause, and fix were verified by hand at the SHAs above; structured review round clean ("patch is correct", including the declare-vs-rename design question).

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS labels Jul 3, 2026
@clawsweeper

clawsweeper Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 3, 2026, 8:00 AM ET / 12:00 UTC.

Summary
The PR adds a dev entry to the local agents.list in src/gateway/gateway.test.ts for the e2e request that uses agent:dev:mock-openai.

PR surface: Tests +3. Total +3 across 1 file.

Reproducibility: yes. from source inspection and the linked issue's focused before/after evidence. Current main still builds a config without agents.list and then sends agent:dev:mock-openai, which the existing Gateway guard rejects.

Review metrics: none identified.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #99513
Summary: This PR is the focused candidate fix for the open canonical gateway e2e fixture issue; the earlier broader PR is closed unmerged and not a viable replacement.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Next step before merge

  • No ClawSweeper repair job is needed because the PR is already a narrow, reviewable fix with no actionable findings.

Security
Cleared: The diff only changes a local Vitest fixture config and comment; it does not touch security-sensitive runtime, dependency, workflow, or supply-chain surfaces.

Review details

Best possible solution:

Land the narrow test-fixture declaration after normal maintainer review while keeping the deleted-agent runtime guard intact.

Do we have a high-confidence way to reproduce the issue?

Yes from source inspection and the linked issue's focused before/after evidence. Current main still builds a config without agents.list and then sends agent:dev:mock-openai, which the existing Gateway guard rejects.

Is this the best way to solve the issue?

Yes. Declaring the test-local dev agent is the narrowest maintainable fix because it preserves the session identity under test and does not weaken deleted-agent validation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8abc633cf8e2.

Label changes

Label justifications:

  • P2: The PR fixes a clean-main gateway e2e failure that blocks contributor validation but has limited blast radius outside test and CI workflows.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes copied terminal output for the focused gateway test passing after the change and the changed check exiting successfully.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes copied terminal output for the focused gateway test passing after the change and the changed check exiting successfully.
Evidence reviewed

PR surface:

Tests +3. Total +3 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 3 0 +3
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 3 0 +3

What I checked:

  • Current main still has the fixture mismatch: At current main, the first gateway e2e config defines agents.defaults but no agents.list, then sends sessionKey = "agent:dev:mock-openai". (src/gateway/gateway.test.ts:195, 8abc633cf8e2)
  • PR patch declares the requested agent only in the test fixture: The PR head adds list: [{ id: "dev", default: true }] under the same local agents test config, matching the session key without changing runtime Gateway code. (src/gateway/gateway.test.ts:209, 9addbdeb73ce)
  • Gateway guard rejects undeclared agent session keys before dispatch: agent RPC calls respondDeletedAgentSessionForKey before dedupe, media, reset, or dispatch, so the mismatched fixture fails before the accepted-run assertion. (src/gateway/server-methods/agent.ts:1491, 8abc633cf8e2)
  • Agent id contract requires configured ids: resolveDeletedAgentIdFromSessionKey returns the parsed agent id when it is absent from listAgentIds(cfg), and listAgentIds falls back to only the default main id when no list exists. (src/gateway/session-utils.ts:979, 8abc633cf8e2)
  • Latest release has not shipped this fixture repair: Tag v2026.6.11 points at e085fa1a3ffd32d0ea6917e1e6fb4ecbffbb77d2, and that release has the same missing agents.list plus agent:dev:mock-openai session key. (src/gateway/gateway.test.ts:195, e085fa1a3ffd)
  • Related broader PR is closed unmerged: The related broader PR added the same dev test fixture entry but also changed other areas and is closed unmerged, so it does not supersede this focused PR. (src/gateway/gateway.test.ts:209, a4d2fc7bef6e)

Likely related people:

  • Crystora: Authored the merged PR series for deleted-agent session invalidation and runtime validation that exposes this fixture mismatch. (role: introduced deleted-agent guard behavior; confidence: high; commits: 945259ce1558, 386623191f4b; files: src/gateway/session-utils.ts, src/gateway/sessions-resolve.ts, src/gateway/server-methods/sessions.ts)
  • gumadeiras: Merged the deleted-agent fix PR and authored adjacent main-session alias and chat-send guard commits in the same merged series. (role: merger and recent adjacent contributor; confidence: high; commits: 1feb21bb02ac, 569816fbdf71, d51b697f485c; files: src/gateway/session-utils.ts, src/gateway/server-methods/chat.ts, src/gateway/session-store-key.ts)
  • steipete: Local git log -S identifies the commit that carried the agent:dev:mock-openai gateway test surface into this file. (role: test surface history; confidence: medium; commits: aa14835607a9; files: src/gateway/gateway.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jul 3, 2026
@steipete steipete self-assigned this Jul 3, 2026
@steipete
steipete merged commit 153fed7 into openclaw:main Jul 3, 2026
140 of 149 checks passed
@steipete

steipete commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

@masatohoshino
masatohoshino deleted the fix/gateway-e2e-dev-agent-fixture branch July 3, 2026 14:04
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: gateway.test.ts e2e fails on clean main — test config omits the "dev" agent its sessionKey requires

2 participants