feat(2048): Hermes brain for live solo loop — B-direct adapter + AGENT_BRAIN selector#183
Open
youngstar-eth wants to merge 1 commit into
Open
feat(2048): Hermes brain for live solo loop — B-direct adapter + AGENT_BRAIN selector#183youngstar-eth wants to merge 1 commit into
youngstar-eth wants to merge 1 commit into
Conversation
…T_BRAIN selector Adds an OpenRouter Hermes 3 (Nous Research) brain to the live 2048 solo loop as a drop-in alternative to the Claude brain, selectable per-deploy via the AGENT_BRAIN env. Move-generation only: the duel_moves insert, reasoning capture, on-chain submitSoloScore path, and DB schema are untouched and brain-agnostic. Why B-direct (not @skillos/hermes-mcp-wrapper.run()): the wrapper's run()/MCP surface owns game state in an MCP session_store and loops multiple turns internally — the wrong shape for the runner's one-call-one-move contract. Instead we use the `openai` SDK pointed at OpenRouter's base URL: a single chat.completions.create per move with a forced make_move function tool, preserving the structured-output guarantee (no free-text parsing). - NEW hermes-agent.ts: exact mirror of anthropic-agent.ts (same getNextMove contract, prompt, board rendering, legal-move validation + illegal-move fallback). Post-response extraction isolated in pure exported parseMoveResponse() so it is unit-testable without an API key. temperature 0.3 (between Anthropic's 0.4 and the wrapper's deterministic 0). - NEW hermes-client.ts: lazy OpenRouter client reading OPENROUTER_API_KEY; AGENT_MATCH_MODEL pinned to hermes-3-llama-3.1-405b; 70B fallback noted for the B4 latency call; display 'Hermes 3 405B (Nous)'. - runner.ts: import swapped to AGENT_BRAIN selector (loadBrain, literal import() specifiers, default 'claude'); resolved once per match. B4: match wall-clock budget (MATCH_MAX_DURATION_SECONDS / MATCH_TIMEOUT_MARGIN_SECONDS) exposed via env with defaults preserving the original Claude-path timing. - package.json: add openai ^4.77.0 (resolves 4.104.0). - vercel.json: add openai to function includeFiles (companion to the dep; the Claude path's @Anthropic-AI is already listed). prepare-bundle.sh's npm-ls pass also picks it up automatically. - .env.example: document AGENT_BRAIN, OPENROUTER_API_KEY, and the B4 knobs. - scripts/hermes-dryrun.ts: dry-run harness. --mock = offline parseMoveResponse logic check (no key); live mode calls the real brain against 3 sample boards and reports per-move + median latency. Verification (this stage, no live on-chain / no deploy): - typecheck (tsc --noEmit) green; lint green. - mock dry-run 8/8: valid passthrough, illegal→fallback, missing-tool / bad-JSON / invalid-direction all throw; 3 sample boards expose legal moves. - Claude path regression-free: anthropic-agent.ts byte-unchanged; selector defaults to 'claude'; duel_moves + submitSoloScore hunks byte-identical. Live median latency (405B) is PENDING a founder-run of the dry-run with a real OPENROUTER_API_KEY — feeds the 405B-vs-70B model decision. OPENROUTER_API_KEY must be provisioned on the Vercel app-api project (NOT in this PR). Apex /watch model-name render lives in the sibling skillbase-apex repo — out of scope here. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an OpenRouter Hermes 3 (Nous Research) brain to the live 2048 solo loop as a drop-in alternative to the Claude brain, selectable per-deploy via the
AGENT_BRAINenv. Move-generation only — theduel_movesinsert, reasoning capture, on-chainsubmitSoloScorepath, and DB schema are untouched and brain-agnostic.Do NOT merge / deploy yet. This stage is build + local dry-run only. No live on-chain run, no deploy, no Vercel env writes.
Why B-direct (not
@skillos/hermes-mcp-wrapper.run())The wrapper's
run()/MCP surface owns game state in an MCPsession_storeand loops multiple turns internally — the wrong shape for the runner's one-call-one-move contract. Instead we use theopenaiSDK pointed at OpenRouter's base URL: a singlechat.completions.createper move with a forcedmake_movefunction tool, preserving the structured-output guarantee (no free-text parsing).Change-set
apps/api/src/lib/duel/hermes-agent.ts(NEW)anthropic-agent.ts— samegetNextMove(ctx)contract, prompt, board rendering, legal-move validation + illegal-move fallback. Post-response extraction isolated in pure exportedparseMoveResponse()(unit-testable without a key).temperature 0.3.apps/api/src/lib/duel/hermes-client.ts(NEW)OPENROUTER_API_KEY;AGENT_MATCH_MODELpinned tohermes-3-llama-3.1-405b; 70B fallback noted for B4; displayHermes 3 405B (Nous).apps/api/src/lib/duel/runner.tsAGENT_BRAINselector (loadBrain, literalimport()specifiers, default'claude'), resolved once per match. B4: match wall-clock budget exposed viaMATCH_MAX_DURATION_SECONDS/MATCH_TIMEOUT_MARGIN_SECONDSenv with defaults preserving the original Claude-path timing.apps/api/package.jsonopenai ^4.77.0(resolves 4.104.0).apps/api/vercel.jsonopenaito functionincludeFiles(companion to the dep; the Claude path's@anthropic-aiis already listed).prepare-bundle.sh'snpm lspass also copies it automatically.apps/api/.env.exampleAGENT_BRAIN,OPENROUTER_API_KEY, and the B4 knobs.apps/api/scripts/hermes-dryrun.ts(NEW)--mock= offlineparseMoveResponselogic check (no key); live mode calls the real brain against 3 sample boards and reports per-move + median latency.Verification (this stage)
tsc --noEmitgreen;eslintgreen.anthropic-agent.tsbyte-unchanged; selector defaults to'claude';duel_moves+submitSoloScorehunks byte-identical.OPENROUTER_API_KEY(local env only). This number feeds the 405B-vs-70B model decision (B4): if 405B per-move latency blows the wall-clock move budget, flipAGENT_MATCH_MODELto the 70B fallback noted inhermes-client.ts.OPENROUTER_API_KEYmust be provisioned on the Vercelapp-apiproject by the founder before any Hermes-path deploy — not committed here./watchmodel-name render lives in the siblingskillbase-apexrepo (currently may show "Claude Haiku 4.5") — out of scope here; flag for a separate sister check.🤖 Generated with Claude Code