Skip to content

[Follow-up] Modify .github/workflows/agents-auto-pilot.yml to (PR #1447) #1453

Description

@stranske

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)

  • Remove the unconditional skip logic from tests/workflows/test_workflow_llm_installs.py so tests run in normal CI
  • Add assertion to tests/workflows/test_workflow_llm_installs.py to verify agents-auto-pilot workflow contains the pinned install step and lacks unpinned langchain commands
  • Add assertions to tests/workflows/test_workflow_llm_installs.py to verify reusable-agents-verifier workflow contains pinned install steps in both evaluate and compare modes
  • Add assertions to tests/workflows/test_workflow_llm_installs.py to verify both workflows include actions/cache@v4 with correct cache keys containing Python version and requirements hash
  • Add unit tests to validate check_prompt_injection() handles malformed detector outputs without raising exceptions
  • Add unit tests to validate check_prompt_injection() correctly handles known-good reason code formats

Code Hardening (Agent-Executable)

  • Update check_prompt_injection() to validate detector output format before parsing (check prefix/delimiters and guard integer conversion)
  • Implement safe fallback path in check_prompt_injection() for unexpected formats (no exception, defined behavior)

Workflow Update Snippets (Agent-Executable)

  • Create docs/workflow-updates/agents-auto-pilot-changes.yml with complete YAML snippet for pip install step and cache configuration
  • Create docs/workflow-updates/reusable-agents-verifier-changes.yml with complete YAML snippets for evaluate/compare mode pip install steps and cache configuration
  • Add docs/workflow-updates/README.md with instructions for applying the YAML snippets to protected workflow files

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.

  • Add a dedicated step to .github/workflows/agents-auto-pilot.yml that executes pip install -r tools/requirements-llm.txt
  • Remove all unpinned pip install langchain* commands from .github/workflows/agents-auto-pilot.yml
  • Add a step to .github/workflows/reusable-agents-verifier.yml evaluate mode that executes pip install -r .workflows-lib/tools/requirements-llm.txt
  • Add a step to .github/workflows/reusable-agents-verifier.yml compare mode that executes pip install -r .workflows-lib/tools/requirements-llm.txt
  • Remove all unpinned pip install langchain* commands from evaluate and compare modes in .github/workflows/reusable-agents-verifier.yml
  • Add actions/cache@v4 pip cache step to .github/workflows/agents-auto-pilot.yml with cache key including Python version and hashFiles('tools/requirements-llm.txt')
  • Add actions/cache@v4 pip cache step to .github/workflows/reusable-agents-verifier.yml with cache key including Python version and hashFiles('.workflows-lib/tools/requirements-llm.txt')

Acceptance Criteria

Workflow Files (Human-Applied)

  • .github/workflows/agents-auto-pilot.yml contains a step that executes exactly pip install -r tools/requirements-llm.txt (as a run command in the workflow)
  • .github/workflows/agents-auto-pilot.yml does NOT contain any pip install commands that install langchain via an unpinned specifier, including (but not limited to) pip install langchain, pip install langchain*, pip install langchain== (missing version), or pip install git+...langchain...
  • .github/workflows/reusable-agents-verifier.yml includes a step that executes exactly pip install -r .workflows-lib/tools/requirements-llm.txt in the evaluate mode execution path
  • .github/workflows/reusable-agents-verifier.yml includes a step that executes exactly pip install -r .workflows-lib/tools/requirements-llm.txt in the compare mode execution path
  • .github/workflows/reusable-agents-verifier.yml does NOT contain any pip install commands 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-community without a version pin)
  • .github/workflows/agents-auto-pilot.yml contains an actions/cache@v4 step 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.yml contains an actions/cache@v4 step 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.py is 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 step
  • tests/workflows/test_workflow_llm_installs.py asserts that .github/workflows/agents-auto-pilot.yml contains pip install -r tools/requirements-llm.txt AND asserts it does not contain any floating pip install langchain*/unversioned langchain install commands
  • tests/workflows/test_workflow_llm_installs.py asserts that .github/workflows/reusable-agents-verifier.yml contains pip install -r .workflows-lib/tools/requirements-llm.txt for BOTH evaluate and compare modes (separate assertions per mode/path, not a single generic check)
  • tests/workflows/test_workflow_llm_installs.py asserts that BOTH workflows include an actions/cache@v4 step and that each cache key includes Python version + the correct hashFiles(...) call for the correct requirements path

Code Hardening

  • check_prompt_injection() does not raise an exception when detect_prompt_injection returns 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 value
  • Unit tests pass that verify check_prompt_injection() behavior with both malformed and known-good detector outputs

Documentation Deliverables

  • docs/workflow-updates/agents-auto-pilot-changes.yml exists and contains valid YAML snippet for pip install and cache steps
  • docs/workflow-updates/reusable-agents-verifier-changes.yml exists and contains valid YAML snippets for evaluate/compare mode pip install and cache steps
  • docs/workflow-updates/README.md exists and provides clear instructions for applying the YAML snippets to the protected workflow files

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions