Skip to content

Generalize CodexAgentBackend → LLMAgentBackend (#234) - #363

Closed
larstalian wants to merge 1 commit into
mainfrom
generalize-agent-backend-234
Closed

larstalian wants to merge 1 commit into
mainfrom
generalize-agent-backend-234

Conversation

@larstalian

Copy link
Copy Markdown
Contributor

Summary

CodexAgentBackend had no codex-specific code — it just wraps any LLMBackend into a single-shot, tool-less AgentBackend, defaulting to CodexBackend when none is passed. This renames it to LLMAgentBackend so the name reflects what it actually does, leaving "Codex" in exactly one place (CodexBackend).

  • Clean rename, no backward-compat alias (repo is pre-1.0; an alias would defeat the point of Generalize CodexAgentBackend — it's not actually codex-specific #234).
  • The CodexBackend default fallback stays intact — that's the one legitimate Codex reference. Error strings/docstrings updated to say LLMAgentBackend.
  • Updated every reference: agent_backend.py, __init__.py (import + __all__), tests/test_agent_backend.py, tests/test_office_persona.py, examples/codex_eval.py (class ref; file name kept), pack-sdk _protocols.py comment, and pack-sdk README.md prose.
  • grep CodexAgentBackend across the repo → zero hits.

Test plan

  • ruff check on all touched files — passed
  • mypy on agent_backend.py, __init__.py, examples/codex_eval.py — passed
  • pytest tests/test_agent_backend.py tests/test_office_persona.py — 31 passed

Closes #234

🤖 Generated with Claude Code

CodexAgentBackend had no codex-specific code — it just wraps any
LLMBackend into a single-shot, tool-less AgentBackend, defaulting to
CodexBackend when none is passed. Rename to LLMAgentBackend so the name
reflects that it takes any LLMBackend and "Codex" appears in exactly one
place (CodexBackend). Clean rename, no backward-compat alias (pre-1.0).
The CodexBackend default fallback stays intact.

Closes #234

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@larstalian

Copy link
Copy Markdown
Contributor Author

Review — Generalize CodexAgentBackend → LLMAgentBackend (#234)

Verdict: CHANGES-REQUESTED (one small, concrete change). The core rename is correct, minimal, and well-scoped; I verified every claim locally. One residual inconsistency should be cleaned up before merge because it directly undercuts the goal of #234.

Verified locally (branch generalize-agent-backend-234)

  • rg CodexAgentBackend across the whole repo → zero hits. Import, __all__, class def, docstrings, error strings, both test modules, examples/codex_eval.py, pack-sdk _protocols.py comment, and pack-sdk README.md prose are all updated. ✅
  • CodexBackend default-fallback preserved intact (agent_backend.py L77 docstring, L91 else CodexBackend(model=model)) — the one legitimate Codex reference. ✅
  • Error-string change is in sync with assertions: test_codex_backend_rejects_tools matches on the substring "does not support tool injection" and the office_persona fake raises the same updated text, so no assertion drift. ✅
  • ruff check on all 6 touched files → clean. mypy src/openrange/agent_backend.py → clean.
  • pytest tests/test_agent_backend.py tests/test_office_persona.py → 29 passed, 2 skipped. The 2 skips are pre-existing (strands not installed), unrelated to this change. Matches the PR's "31 collected" claim.
  • Pure rename → no new abstractions, no behavior change, coverage not regressed. No mocks/patch/test-double libraries introduced. ✅

Must fix before merge — stale codex naming in the test suite

The rename dropped the CodexAgentBackend symbol but left the old codex framing on identifiers that now exercise the generic backend. This contradicts #234's stated goal ("Codex should appear in exactly one place") and, more concretely, creates name/docstring mismatches that violate .rules ("well-named identifiers", no misleading names):

  • tests/test_agent_backend.py: test_codex_backend_rejects_tools, test_codex_backend_drives_llm_for_tool_less_prompts, test_codex_backend_rejects_both_backend_and_model_args, test_codex_backend_preflight_delegates_to_custom_llm_backend, test_codex_backend_preflight_surfaces_custom_llm_backend_failures — these now test LLMAgentBackend with a plain _RecordingLLMBackend (nothing codex-specific), and their docstrings already say "LLMAgentBackend" while the function names still say codex_backend. Rename them test_llm_agent_backend_*.
  • test_codex_backend_preflight_errors_if_codex_cli_missing is the one that legitimately drives the real CodexBackend (match="codex CLI not found"); the codex_cli_missing half is fine — just drop the codex_backend_ prefix.

Should reconcile (your call, not a blocker)

  • tests/test_office_persona.py _CodexLikeBackend and the codex_like_backend param id: defensible since the fake models CodexBackend's tool-rejecting shape, but its docstring now reads "mimics real LLMAgentBackend", so the name/intent are slightly crossed. Either rename to _ToolRejectingBackend or keep and make the docstring say it mimics a tool-less/CodexBackend-shaped backend.

Good

Clean pre-1.0 rename with no back-compat alias (correct — an alias would defeat #234). Diff is tight (29/28), touches exactly the right files including the two easily-missed spots (pack-sdk README prose + _protocols.py comment). Behavior byte-for-byte identical. This is mergeable as soon as the test_codex_backend_* function names are generalized.

@larstalian

Copy link
Copy Markdown
Contributor Author

Code review — #234 CodexAgentBackend → LLMAgentBackend

Verdict: APPROVE (with two optional, non-blocking cleanups noted below).

Reviewed the diff against the repo's .rules, CONTRACTS.md/DESIGN.md, and issue #234's intent ("Codex" in exactly one place). Verified locally on origin/generalize-agent-backend-234.

What I checked

  • Rename complete & consistent — git grep -n CodexAgentBackend → zero hits repo-wide (src, tests, examples, docstrings/comments, pack-sdk README.md + _protocols.py). ✅
  • CodexBackend default fallback preserved — constructor still does backend if backend is not None else CodexBackend(model=model) (agent_backend.py:91); the "pass either 'backend' or 'model'" guard is intact. This is the one legitimate, intentional Codex reference. ✅
  • Error strings in sync — the runtime string "LLMAgentBackend does not support tool injection. …" (agent_backend.py:116) matches the office-persona fixture string (test_office_persona.py:89) and the end-to-end comment (:305). test_agent_backend.py:96 matches on the class-agnostic substring "does not support tool injection", so it's robust. ✅
  • Remaining Codex occurrences are all legitimate — CodexBackend, the codex CLI, examples/codex_eval.py (file kept, class ref updated), and README "Codex-backed eval" prose. None reintroduce the old class name. ✅
  • .rules compliance — pure rename, no new abstractions, minimal diff; public-class docstring is concise and explains the default-fallback semantics (allowed for public classes). No stray __all__ in leaf modules; __init__.py __all__ updated and stays alphabetized. ✅
  • Gates (run locally with uv) — ruff check on all 5 touched files: clean. mypy on agent_backend.py/__init__.py/examples/codex_eval.py: clean (3 files). pytest tests/test_agent_backend.py tests/test_office_persona.py: 29 passed, 2 skipped (strands optional dep). No control-flow change → branch coverage not regressed. ✅

Non-blocking nits (optional, your call)

  1. Stale codex test identifiers. The 7 test_codex_backend_* function names in test_agent_backend.py and the _CodexLikeBackend fixture in test_office_persona.py now exercise LLMAgentBackend. Their docstrings were updated but the identifiers still say "codex", which slightly undercuts Generalize CodexAgentBackend — it's not actually codex-specific #234's "Codex in one place" spirit. Cosmetic — doesn't affect the CodexAgentBackend grep or behavior — but a test_llm_agent_backend_* / _ToolRejectingBackend rename would finish the job cleanly.
  2. PR description count. Body says "31 passed"; actual is 29 passed + 2 skipped (the 2 strands tests skip without the optional dep). Description-only.

Out of scope (flagging, not blocking)

Clean, correct, minimal. Good to merge once you decide on nit #1.

@larstalian larstalian closed this Oct 12, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generalize CodexAgentBackend — it's not actually codex-specific

1 participant