From d8aeb6d3eaca7da5da1b7a54b07ce0ff646f3a08 Mon Sep 17 00:00:00 2001 From: Varun Poojari <83573233+Varunpoojari@users.noreply.github.com> Date: Fri, 20 Nov 2026 11:10:04 +0000 Subject: [PATCH 1/2] fix: drop the obsolete secfoo[api] extra and its misleading install hint litellm and langgraph are regular dependencies, so the `api` extra installed nothing and `pip install "secfoo[api]"` could not fix a failed import. Remove the empty extra and make the error text, docs/agents.md and the test agree: an import failure means a broken install, so the message says to reinstall secfoo and includes the ImportError. Add a consistency test so the extra cannot return. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01DsERxaCi7rNtqUTYked7Jd --- docs/agents.md | 6 +++--- pyproject.toml | 7 +++---- src/secfoo/agents/api.py | 11 +++++++++-- tests/test_agents/test_api.py | 7 +++++-- tests/test_docs_consistency.py | 17 +++++++++++++++++ 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/docs/agents.md b/docs/agents.md index 25122c6..bb2c713 100644 --- a/docs/agents.md +++ b/docs/agents.md @@ -18,7 +18,7 @@ brackets indicate optional arguments. All CLI processes run in `WORKDIR`. | `copilot` | The adapter identifies the npm package as `@github/copilot`; install and authentication commands are unverified. `copilot [--model MODEL] --output-format json --allow-all-tools` (prompt on stdin). Tools, including writes, are auto-approved: read-only behavior relies on review instructions, not a sandbox. | | `droid` | Install command unverified. Set `FACTORY_API_KEY` for noninteractive use. `droid exec [-m MODEL] --output-format json --cwd WORKDIR -- PROMPT`. Droid defaults to read-only; a full authenticated secfoo run was not verified in the adapter. | | `devin` | The adapter identifies the official Homebrew cask as `devin-cli`; install command unverified. Authenticate beforehand with `devin auth login`; credential reuse for headless runs is unverified. `devin -p PROMPT --respect-workspace-trust false --permission-mode auto`. The combined command and an authenticated end-to-end run are unverified; `auto` is documented by the CLI as approving read-only tools. | -| `api` | No agent binary is invoked. If dependencies are missing, run `pip install "secfoo[api]"`. Set `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, or `GEMINI_API_KEY`. Source files are included in the API prompt. Model selection uses the configured model, then `SECFOO_API_MODEL`, then `openai/gpt-4.1-mini`. | +| `api` | No agent binary is invoked. `litellm` and `langgraph` are installed with secfoo; if importing them fails, reinstall it with `pip install --force-reinstall secfoo`. Set `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, or `GEMINI_API_KEY`. Source files are included in the API prompt. Model selection uses the configured model, then `SECFOO_API_MODEL`, then `openai/gpt-4.1-mini`. | `agy` and `devin` do not support adapter model selection; secfoo warns and ignores a requested model. Other CLI model flags are shown above. @@ -44,8 +44,8 @@ ignores a requested model. Other CLI model flags are shown above. try another agent if it remains unreliable. Claude can put an error reason in stdout JSON even when stderr is empty; secfoo extracts it. - API `not_configured`: `No API key set. Set one of: OPENAI_API_KEY, - ANTHROPIC_API_KEY, GEMINI_API_KEY`. Missing LiteLLM/LangGraph dependencies - produce `failed` with the install command above. + ANTHROPIC_API_KEY, GEMINI_API_KEY`. If LiteLLM or LangGraph cannot be imported, + the run is `failed` and the error says to reinstall secfoo. For a run failure, see `~/.secfoo/reports//stderr.log`; see [Reporting bugs](../CONTRIBUTING.md#reporting-bugs) for what to include diff --git a/pyproject.toml b/pyproject.toml index d76fa48..6045df8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,10 +69,9 @@ dependencies = [ [project.optional-dependencies] dev = ["jsonschema>=4.26.0", "pytest>=9.2.0", "pytest-cov>=7.1.0", "hypothesis>=6.168.5", "httpx>=0.28.1", "ruff>=0.17.5", "bandit>=1.9.4", "pip-audit>=2.10.1", "langgraph>=1.2.21"] build = ["pyinstaller>=6.22.3"] -# The `api` agent (secfoo/agents/api.py): a LangGraph workflow that calls OpenAI/Anthropic/Gemini -# through LiteLLM with an API key instead of driving an installed agent CLI. -# (dev includes langgraph so the real graph runs in tests; litellm is faked.) -api = ["litellm>=1.109.1", "langgraph>=1.2.21"] +# The `api` agent (secfoo/agents/api.py) needs litellm and langgraph, which are regular +# dependencies above, so there is no separate `api` extra to install. +# (dev lists langgraph too so the real graph runs in tests; litellm is faked.) [project.urls] Homepage = "https://secfoo.com" diff --git a/src/secfoo/agents/api.py b/src/secfoo/agents/api.py index ddae6ab..819dac9 100644 --- a/src/secfoo/agents/api.py +++ b/src/secfoo/agents/api.py @@ -322,9 +322,16 @@ def run(self, prompt: str, *, workdir: Path, timeout: int | None = None, prev_co try: import litellm from langgraph.graph import END, START, StateGraph - except ImportError: + except ImportError as exc: + # litellm and langgraph are regular dependencies of secfoo, so a failed + # import means a broken or partial install, not a missing extra. return self._result( - "failed", started, stderr='litellm/langgraph are not installed. Run: pip install "secfoo[api]"' + "failed", + started, + stderr=( + f"litellm/langgraph could not be imported ({exc}). Both are installed with secfoo, " + "so reinstall it: pip install --force-reinstall secfoo" + ), ) try: final = build_graph(litellm, StateGraph, START, END).invoke({ diff --git a/tests/test_agents/test_api.py b/tests/test_agents/test_api.py index acaa786..962d38c 100644 --- a/tests/test_agents/test_api.py +++ b/tests/test_agents/test_api.py @@ -234,14 +234,17 @@ def test_run_strips_a_trailing_newline_from_the_key(tmp_path, monkeypatch): assert api.os.environ["OPENAI_API_KEY"] == "sk-test" -def test_run_without_litellm_installed_says_how_to_install_it(tmp_path, monkeypatch): +def test_run_without_litellm_installed_says_to_reinstall_secfoo(tmp_path, monkeypatch): monkeypatch.setenv("OPENAI_API_KEY", "sk-test") monkeypatch.setitem(sys.modules, "litellm", None) # makes `import litellm` raise ImportError result = ApiAdapter().run("prompt", workdir=tmp_path) assert result.status == "failed" - assert "secfoo[api]" in result.stderr + # litellm/langgraph are base dependencies; there is no `secfoo[api]` extra to point at. + assert "secfoo[api]" not in result.stderr + assert "litellm" in result.stderr + assert "pip install --force-reinstall secfoo" in result.stderr def test_incomplete_report_is_reformatted_once_without_resending_source(tmp_path, monkeypatch): diff --git a/tests/test_docs_consistency.py b/tests/test_docs_consistency.py index e7256ce..6a72d32 100644 --- a/tests/test_docs_consistency.py +++ b/tests/test_docs_consistency.py @@ -55,3 +55,20 @@ def test_the_on_block_parser_sees_triggers_after_a_blank_line() -> None: assert _has_push_trigger(_top_level_on_block('"on": [push, workflow_dispatch]\njobs: {}\n')) commented = "on:\n workflow_dispatch:\n\n# the GHCR push needs packages: write\njobs: {}\n" assert not _has_push_trigger(_top_level_on_block(commented)) + + +def test_no_obsolete_api_extra() -> None: + """litellm and langgraph are base dependencies, so `secfoo[api]` must not come back.""" + try: + import tomllib + except ModuleNotFoundError: # Python 3.10 + import tomli as tomllib + + project = tomllib.loads((ROOT / "pyproject.toml").read_text(encoding="utf-8"))["project"] + assert "api" not in project.get("optional-dependencies", {}) + base = {dep.split(">")[0].split("[")[0].strip() for dep in project["dependencies"]} + assert {"litellm", "langgraph"} <= base + + files = [ROOT / "README.md", ROOT / "CONTRIBUTING.md", *sorted((ROOT / "docs").rglob("*.md")), *sorted((ROOT / "src").rglob("*.py"))] + offenders = [str(path.relative_to(ROOT)) for path in files if "secfoo[api]" in path.read_text(encoding="utf-8")] + assert offenders == [] From 1757a80b4d91a7b39ea471360ca10d6eb334b853 Mon Sep 17 00:00:00 2001 From: Satyanarayana Vuppala Date: Fri, 20 Nov 2026 12:11:46 +0000 Subject: [PATCH 2/2] Point pipx users at pipx reinstall; widen the secfoo[api] guard README's first install channel is pipx, where 'pip install --force-reinstall' would install into a different environment. The consistency test now parses requirement names robustly and also scans action.yml, the Dockerfile, the npm README and the CI examples. Co-Authored-By: Claude Opus 5.5 --- docs/agents.md | 2 +- src/secfoo/agents/api.py | 3 ++- tests/test_agents/test_api.py | 2 ++ tests/test_docs_consistency.py | 7 +++++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/agents.md b/docs/agents.md index bb2c713..d48c781 100644 --- a/docs/agents.md +++ b/docs/agents.md @@ -18,7 +18,7 @@ brackets indicate optional arguments. All CLI processes run in `WORKDIR`. | `copilot` | The adapter identifies the npm package as `@github/copilot`; install and authentication commands are unverified. `copilot [--model MODEL] --output-format json --allow-all-tools` (prompt on stdin). Tools, including writes, are auto-approved: read-only behavior relies on review instructions, not a sandbox. | | `droid` | Install command unverified. Set `FACTORY_API_KEY` for noninteractive use. `droid exec [-m MODEL] --output-format json --cwd WORKDIR -- PROMPT`. Droid defaults to read-only; a full authenticated secfoo run was not verified in the adapter. | | `devin` | The adapter identifies the official Homebrew cask as `devin-cli`; install command unverified. Authenticate beforehand with `devin auth login`; credential reuse for headless runs is unverified. `devin -p PROMPT --respect-workspace-trust false --permission-mode auto`. The combined command and an authenticated end-to-end run are unverified; `auto` is documented by the CLI as approving read-only tools. | -| `api` | No agent binary is invoked. `litellm` and `langgraph` are installed with secfoo; if importing them fails, reinstall it with `pip install --force-reinstall secfoo`. Set `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, or `GEMINI_API_KEY`. Source files are included in the API prompt. Model selection uses the configured model, then `SECFOO_API_MODEL`, then `openai/gpt-4.1-mini`. | +| `api` | No agent binary is invoked. `litellm` and `langgraph` are installed with secfoo; if importing them fails, reinstall secfoo the way you installed it (`pipx reinstall secfoo` or `pip install --force-reinstall secfoo`). Set `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, or `GEMINI_API_KEY`. Source files are included in the API prompt. Model selection uses the configured model, then `SECFOO_API_MODEL`, then `openai/gpt-4.1-mini`. | `agy` and `devin` do not support adapter model selection; secfoo warns and ignores a requested model. Other CLI model flags are shown above. diff --git a/src/secfoo/agents/api.py b/src/secfoo/agents/api.py index 819dac9..4ac27ae 100644 --- a/src/secfoo/agents/api.py +++ b/src/secfoo/agents/api.py @@ -330,7 +330,8 @@ def run(self, prompt: str, *, workdir: Path, timeout: int | None = None, prev_co started, stderr=( f"litellm/langgraph could not be imported ({exc}). Both are installed with secfoo, " - "so reinstall it: pip install --force-reinstall secfoo" + "so reinstall it the way you installed it: pipx reinstall secfoo, " + "or pip install --force-reinstall secfoo" ), ) try: diff --git a/tests/test_agents/test_api.py b/tests/test_agents/test_api.py index 962d38c..7cca3d3 100644 --- a/tests/test_agents/test_api.py +++ b/tests/test_agents/test_api.py @@ -244,6 +244,8 @@ def test_run_without_litellm_installed_says_to_reinstall_secfoo(tmp_path, monkey # litellm/langgraph are base dependencies; there is no `secfoo[api]` extra to point at. assert "secfoo[api]" not in result.stderr assert "litellm" in result.stderr + # README's first install channel is pipx, where `pip install` would hit the wrong environment. + assert "pipx reinstall secfoo" in result.stderr assert "pip install --force-reinstall secfoo" in result.stderr diff --git a/tests/test_docs_consistency.py b/tests/test_docs_consistency.py index 6a72d32..4a7247f 100644 --- a/tests/test_docs_consistency.py +++ b/tests/test_docs_consistency.py @@ -66,9 +66,12 @@ def test_no_obsolete_api_extra() -> None: project = tomllib.loads((ROOT / "pyproject.toml").read_text(encoding="utf-8"))["project"] assert "api" not in project.get("optional-dependencies", {}) - base = {dep.split(">")[0].split("[")[0].strip() for dep in project["dependencies"]} + base = {re.split(r"[\s<>=!~;\[]", dep, maxsplit=1)[0].lower() for dep in project["dependencies"]} assert {"litellm", "langgraph"} <= base - files = [ROOT / "README.md", ROOT / "CONTRIBUTING.md", *sorted((ROOT / "docs").rglob("*.md")), *sorted((ROOT / "src").rglob("*.py"))] + files = [ROOT / "README.md", ROOT / "CONTRIBUTING.md", ROOT / "action.yml", ROOT / "Dockerfile", + *sorted((ROOT / "docs").rglob("*.md")), *sorted((ROOT / "src").rglob("*.py")), + *sorted((ROOT / "npm").rglob("*.md")), *sorted((ROOT / "examples").rglob("*.yml"))] + files = [path for path in files if path.is_file()] offenders = [str(path.relative_to(ROOT)) for path in files if "secfoo[api]" in path.read_text(encoding="utf-8")] assert offenders == []