Workflow LLM Dependency Pinning and Test Enforcement
Why
PR #1447 addressed issue #1437, but verification failed because the actual workflow files were not updated to use pinned LLM dependency installs and proper pip caching, and the enforcement tests were effectively skipped in normal CI. This follow-up closes the remaining gaps by updating the live GitHub Actions workflows, enabling non-skipped enforcement tests, and hardening check_prompt_injection() to avoid runtime errors on malformed detector outputs.
Source
Tasks
Test Updates (Agent-Executable)
Code Hardening (Agent-Executable)
Workflow Update Snippets (Agent-Executable)
Deferred Tasks (Requires Human)
Note: The following tasks require modifications to protected .github/workflows/ files that cannot be modified by the agent. YAML snippets will be provided in docs/workflow-updates/ for human review and application.
Acceptance Criteria
Workflow Files (Human-Applied)
Test Enforcement
Code Hardening
Documentation Deliverables
Implementation Notes
Agent-Executable Work
Tests:
- Update
tests/workflows/test_workflow_llm_installs.py to remove unconditional skip logic (e.g., gating on AGENT_ENV == 'agent-high-privilege')
- Add explicit assertions for:
- Presence of the exact pinned
pip install -r ... commands
- Absence of floating/unpinned
pip install ... langchain... patterns
- Presence and correctness of
actions/cache@v4 and cache key contents (Python version + correct hashFiles(...))
- Prefer robust checks (YAML parsing where feasible) rather than only substring matching; if regex scanning is used, ensure it cannot be bypassed by formatting differences
check_prompt_injection() hardening:
- Validate the detector output format before parsing (e.g., check prefix/delimiters; guard integer conversion)
- On unexpected formats, follow a safe fallback path (no exception)
- Add/extend unit tests by stubbing/mocking
detect_prompt_injection for both malformed and known-good return values
Workflow Update Snippets:
Create complete, ready-to-apply YAML snippets in docs/workflow-updates/ directory:
agents-auto-pilot-changes.yml - Contains the pip install step and cache configuration for agents-auto-pilot workflow
reusable-agents-verifier-changes.yml - Contains the pip install steps for evaluate/compare modes and cache configuration
README.md - Instructions for human to apply these snippets to the protected workflow files
Human-Required Work
Workflow Changes:
- Make changes directly in the live workflow files:
.github/workflows/agents-auto-pilot.yml: add a dedicated step with run: pip install -r tools/requirements-llm.txt and remove any separate pip install langchain... commands
.github/workflows/reusable-agents-verifier.yml: ensure both evaluate and compare gated paths include run: pip install -r .workflows-lib/tools/requirements-llm.txt, and remove/avoid unpinned langchain installs in those paths
- Add
actions/cache@v4 for pip caching in both workflows:
- Use a pip cache path (commonly
~/.cache/pip)
- Cache key must combine Python version + requirements hash:
- agents-auto-pilot: include
hashFiles('tools/requirements-llm.txt')
- reusable-agents-verifier: include
hashFiles('.workflows-lib/tools/requirements-llm.txt')
Background (previous attempt context)
- The agent only updated documentation snippets and tests without modifying the actual workflow files (
.github/workflows/agents-auto-pilot.yml and .github/workflows/reusable-agents-verifier.yml). This failed because documentation changes did not propagate to the live workflow configurations.
- The test for workflow enforcement is skipped under standard environments. Skipping tests unless
AGENT_ENV is agent-high-privilege makes it unreliable for catching configuration errors in typical CI/dev environments.
- The PR adds a 'needs-human' documentation comment (
agents/codex-1447.md) acknowledging workflow updates are required, but documentation is not a substitute for implementing the acceptance criteria (post-merge verification is about actual code state).
- Test file
tests/workflows/test_workflow_llm_installs.py skips all assertions when AGENT_ENV != 'agent-high-privilege', meaning the tests cannot verify the acceptance criteria are met.
Workflow LLM Dependency Pinning and Test Enforcement
Why
PR #1447 addressed issue #1437, but verification failed because the actual workflow files were not updated to use pinned LLM dependency installs and proper pip caching, and the enforcement tests were effectively skipped in normal CI. This follow-up closes the remaining gaps by updating the live GitHub Actions workflows, enabling non-skipped enforcement tests, and hardening
check_prompt_injection()to avoid runtime errors on malformed detector outputs.Source
Tasks
Test Updates (Agent-Executable)
tests/workflows/test_workflow_llm_installs.pyso tests run in normal CItests/workflows/test_workflow_llm_installs.pyto verify agents-auto-pilot workflow contains the pinned install step and lacks unpinned langchain commandstests/workflows/test_workflow_llm_installs.pyto verify reusable-agents-verifier workflow contains pinned install steps in both evaluate and compare modestests/workflows/test_workflow_llm_installs.pyto verify both workflows include actions/cache@v4 with correct cache keys containing Python version and requirements hashcheck_prompt_injection()handles malformed detector outputs without raising exceptionscheck_prompt_injection()correctly handles known-good reason code formatsCode Hardening (Agent-Executable)
check_prompt_injection()to validate detector output format before parsing (check prefix/delimiters and guard integer conversion)check_prompt_injection()for unexpected formats (no exception, defined behavior)Workflow Update Snippets (Agent-Executable)
docs/workflow-updates/agents-auto-pilot-changes.ymlwith complete YAML snippet for pip install step and cache configurationdocs/workflow-updates/reusable-agents-verifier-changes.ymlwith complete YAML snippets for evaluate/compare mode pip install steps and cache configurationdocs/workflow-updates/README.mdwith instructions for applying the YAML snippets to protected workflow filesDeferred Tasks (Requires Human)
Note: The following tasks require modifications to protected
.github/workflows/files that cannot be modified by the agent. YAML snippets will be provided indocs/workflow-updates/for human review and application..github/workflows/agents-auto-pilot.ymlthat executespip install -r tools/requirements-llm.txtpip install langchain*commands from.github/workflows/agents-auto-pilot.yml.github/workflows/reusable-agents-verifier.ymlevaluate mode that executespip install -r .workflows-lib/tools/requirements-llm.txt.github/workflows/reusable-agents-verifier.ymlcompare mode that executespip install -r .workflows-lib/tools/requirements-llm.txtpip install langchain*commands from evaluate and compare modes in.github/workflows/reusable-agents-verifier.ymlactions/cache@v4pip cache step to.github/workflows/agents-auto-pilot.ymlwith cache key including Python version andhashFiles('tools/requirements-llm.txt')actions/cache@v4pip cache step to.github/workflows/reusable-agents-verifier.ymlwith cache key including Python version andhashFiles('.workflows-lib/tools/requirements-llm.txt')Acceptance Criteria
Workflow Files (Human-Applied)
.github/workflows/agents-auto-pilot.ymlcontains a step that executes exactlypip install -r tools/requirements-llm.txt(as a run command in the workflow).github/workflows/agents-auto-pilot.ymldoes NOT contain anypip installcommands that install langchain via an unpinned specifier, including (but not limited to)pip install langchain,pip install langchain*,pip install langchain==(missing version), orpip install git+...langchain....github/workflows/reusable-agents-verifier.ymlincludes a step that executes exactlypip install -r .workflows-lib/tools/requirements-llm.txtin the evaluate mode execution path.github/workflows/reusable-agents-verifier.ymlincludes a step that executes exactlypip install -r .workflows-lib/tools/requirements-llm.txtin the compare mode execution path.github/workflows/reusable-agents-verifier.ymldoes NOT contain anypip installcommands that install langchain via an unpinned specifier in the evaluate or compare execution paths (e.g.,pip install langchain*,pip install langchain,pip install langchain-communitywithout a version pin).github/workflows/agents-auto-pilot.ymlcontains anactions/cache@v4step that caches pip (cache path includes pip cache directory) and uses a cache key that includes BOTH the Python version and${{ hashFiles('tools/requirements-llm.txt') }}.github/workflows/reusable-agents-verifier.ymlcontains anactions/cache@v4step that caches pip (cache path includes pip cache directory) and uses a cache key that includes BOTH the Python version and${{ hashFiles('.workflows-lib/tools/requirements-llm.txt') }}Test Enforcement
tests/workflows/test_workflow_llm_installs.pyis executed under normal CI (i.e., it is not unconditionally skipped) and will fail if the agents-auto-pilot workflow lacks the pinned requirements install steptests/workflows/test_workflow_llm_installs.pyasserts that.github/workflows/agents-auto-pilot.ymlcontainspip install -r tools/requirements-llm.txtAND asserts it does not contain any floatingpip install langchain*/unversioned langchain install commandstests/workflows/test_workflow_llm_installs.pyasserts that.github/workflows/reusable-agents-verifier.ymlcontainspip install -r .workflows-lib/tools/requirements-llm.txtfor BOTH evaluate and compare modes (separate assertions per mode/path, not a single generic check)tests/workflows/test_workflow_llm_installs.pyasserts that BOTH workflows include anactions/cache@v4step and that each cache key includes Python version + the correcthashFiles(...)call for the correct requirements pathCode Hardening
check_prompt_injection()does not raise an exception whendetect_prompt_injectionreturns an unexpected or malformed reason code (e.g., empty string, missing delimiter/prefix, non-integer suffix); instead it follows a defined fallback path (e.g., returns a safe default or logs and continues)check_prompt_injection()continues to correctly handle valid reason code formats by producing the same outcome as before for at least one known-good reason code valuecheck_prompt_injection()behavior with both malformed and known-good detector outputsDocumentation Deliverables
docs/workflow-updates/agents-auto-pilot-changes.ymlexists and contains valid YAML snippet for pip install and cache stepsdocs/workflow-updates/reusable-agents-verifier-changes.ymlexists and contains valid YAML snippets for evaluate/compare mode pip install and cache stepsdocs/workflow-updates/README.mdexists and provides clear instructions for applying the YAML snippets to the protected workflow filesImplementation Notes
Agent-Executable Work
Tests:
tests/workflows/test_workflow_llm_installs.pyto remove unconditional skip logic (e.g., gating onAGENT_ENV == 'agent-high-privilege')pip install -r ...commandspip install ... langchain...patternsactions/cache@v4and cache key contents (Python version + correcthashFiles(...))check_prompt_injection()hardening:detect_prompt_injectionfor both malformed and known-good return valuesWorkflow Update Snippets:
Create complete, ready-to-apply YAML snippets in
docs/workflow-updates/directory:agents-auto-pilot-changes.yml- Contains the pip install step and cache configuration for agents-auto-pilot workflowreusable-agents-verifier-changes.yml- Contains the pip install steps for evaluate/compare modes and cache configurationREADME.md- Instructions for human to apply these snippets to the protected workflow filesHuman-Required Work
Workflow Changes:
.github/workflows/agents-auto-pilot.yml: add a dedicated step withrun: pip install -r tools/requirements-llm.txtand remove any separatepip install langchain...commands.github/workflows/reusable-agents-verifier.yml: ensure both evaluate and compare gated paths includerun: pip install -r .workflows-lib/tools/requirements-llm.txt, and remove/avoid unpinned langchain installs in those pathsactions/cache@v4for pip caching in both workflows:~/.cache/pip)hashFiles('tools/requirements-llm.txt')hashFiles('.workflows-lib/tools/requirements-llm.txt')Background (previous attempt context)
.github/workflows/agents-auto-pilot.ymland.github/workflows/reusable-agents-verifier.yml). This failed because documentation changes did not propagate to the live workflow configurations.AGENT_ENVisagent-high-privilegemakes it unreliable for catching configuration errors in typical CI/dev environments.agents/codex-1447.md) acknowledging workflow updates are required, but documentation is not a substitute for implementing the acceptance criteria (post-merge verification is about actual code state).tests/workflows/test_workflow_llm_installs.pyskips all assertions whenAGENT_ENV != 'agent-high-privilege', meaning the tests cannot verify the acceptance criteria are met.