Proposal: fix test-infra-improver — replace bash curl+jq pipelines with MCP Forgejo tools to fix security restriction blocking #5413

Open
opened 2026-04-09 06:34:56 +00:00 by HAL9000 · 0 comments
Owner

Agent Improvement Proposal

Pattern Detected

Type: workflow_fix
Affected Agent: test-infra-improver
Evidence: Issues #5396 and #5401 document that the test-infra-pool supervisor is completely blocked by bash security restrictions. Multiple sessions have failed with the same error: the agent cannot use curl ... | jq ... pipelines or command substitution ($(...)) which are blocked by the security policy.

Detailed Evidence

From issue #5396 (watchdog detection):

"The security constraints of this environment are proving to be a significant challenge, preventing me from checking for new code or even adopting existing workers."

From issue #5401 (test-infra-pool tracking):

"The Test Infrastructure Analysis Pool Supervisor is unable to dispatch any analysis workers due to security restrictions on the bash tool. The supervisor cannot programmatically extract the required session_id from the worker creation API response."

Specific blocked patterns in test-infra-improver.md:

  1. Line 139: local previous_issue=$(curl -s "..." | jq -r '...' | head -1) — blocked (command substitution + pipe)
  2. Line 172: local issue_number=$(echo "$response" | jq -r '.number') — blocked (command substitution)
  3. Worker dispatch: session_id=$(curl -s ... | jq -r '.id') — blocked (command substitution + pipe)

The bash security policy allows:

  • curl * (standalone)
  • jq * (standalone)
  • sleep *
  • echo $*

But does NOT allow:

  • curl ... | jq ... (pipes)
  • $(...) (command substitution)
  • local var=$(...) (variable assignment with command substitution)

Proposed Change

Replace the bash-based tracking functions in test-infra-improver.md with MCP Forgejo tool calls. The agent already has access to Forgejo MCP tools via its task permissions. The tracking functions should be rewritten to use:

  1. forgejo_list_repo_issues instead of curl ... | jq ... to find previous tracking issues
  2. forgejo_issue_state_change instead of curl -X PATCH ... to close issues
  3. forgejo_create_issue instead of curl -X POST ... to create new issues
  4. forgejo_add_issue_labels instead of curl -X PUT .../labels to apply labels

For worker dispatch (which requires the OpenCode Server API, not Forgejo), the agent should use the async-agent-starter task subagent instead of raw curl commands.

Specific changes needed:

  1. Add async-agent-starter to the task permissions in the frontmatter
  2. Replace all bash tracking functions with MCP tool call instructions
  3. Replace worker dispatch curl commands with async-agent-starter task invocations
  4. Remove the bash function definitions (they cannot work in this environment)

Alternative approach (simpler): Add the forgejo_* MCP tools to the agent's permissions and rewrite the tracking section to use direct MCP tool calls instead of bash functions.

Expected Impact

  • test-infra-pool unblocked: The supervisor can dispatch workers and monitor their progress
  • Consistent with other agents: Other agents (like system-watchdog) already use MCP tools for Forgejo operations
  • No more CRITICAL FAILURE tracking issues: The pool will function normally
  • Test infrastructure improvements will resume: Workers can analyze and file issues

Risk Assessment

  • Low risk: This is a pure refactoring of how the agent interacts with Forgejo — the logic and behavior remain the same. Only the mechanism changes (bash curl → MCP tools).
  • Medium complexity: The agent definition needs careful rewriting to use MCP tools correctly. The tracking functions are used in multiple places.
  • Potential concern: If the MCP tools have different behavior than the curl commands (e.g., different error handling), some edge cases might behave differently. However, the current state (complete failure) is worse than any potential edge case.

This is a proposal from the agent evolver. A human must approve this issue before the change will be implemented. To approve: remove the needs feedback label, add State/Verified, or comment with approval.


Automated by CleverAgents Bot
Supervisor: Agent Evolver | Agent: agent-evolver

## Agent Improvement Proposal ### Pattern Detected **Type**: workflow_fix **Affected Agent**: `test-infra-improver` **Evidence**: Issues #5396 and #5401 document that the test-infra-pool supervisor is completely blocked by bash security restrictions. Multiple sessions have failed with the same error: the agent cannot use `curl ... | jq ...` pipelines or command substitution (`$(...)`) which are blocked by the security policy. ### Detailed Evidence From issue #5396 (watchdog detection): > "The security constraints of this environment are proving to be a significant challenge, preventing me from checking for new code or even adopting existing workers." From issue #5401 (test-infra-pool tracking): > "The Test Infrastructure Analysis Pool Supervisor is unable to dispatch any analysis workers due to security restrictions on the `bash` tool. The supervisor cannot programmatically extract the required `session_id` from the worker creation API response." **Specific blocked patterns in `test-infra-improver.md`:** 1. **Line 139**: `local previous_issue=$(curl -s "..." | jq -r '...' | head -1)` — blocked (command substitution + pipe) 2. **Line 172**: `local issue_number=$(echo "$response" | jq -r '.number')` — blocked (command substitution) 3. **Worker dispatch**: `session_id=$(curl -s ... | jq -r '.id')` — blocked (command substitution + pipe) The bash security policy allows: - `curl *` (standalone) - `jq *` (standalone) - `sleep *` - `echo $*` But does NOT allow: - `curl ... | jq ...` (pipes) - `$(...)` (command substitution) - `local var=$(...)` (variable assignment with command substitution) ### Proposed Change Replace the bash-based tracking functions in `test-infra-improver.md` with MCP Forgejo tool calls. The agent already has access to Forgejo MCP tools via its `task` permissions. The tracking functions should be rewritten to use: 1. **`forgejo_list_repo_issues`** instead of `curl ... | jq ...` to find previous tracking issues 2. **`forgejo_issue_state_change`** instead of `curl -X PATCH ...` to close issues 3. **`forgejo_create_issue`** instead of `curl -X POST ...` to create new issues 4. **`forgejo_add_issue_labels`** instead of `curl -X PUT .../labels` to apply labels For worker dispatch (which requires the OpenCode Server API, not Forgejo), the agent should use the `async-agent-starter` task subagent instead of raw curl commands. **Specific changes needed:** 1. Add `async-agent-starter` to the task permissions in the frontmatter 2. Replace all bash tracking functions with MCP tool call instructions 3. Replace worker dispatch curl commands with `async-agent-starter` task invocations 4. Remove the bash function definitions (they cannot work in this environment) **Alternative approach** (simpler): Add the `forgejo_*` MCP tools to the agent's permissions and rewrite the tracking section to use direct MCP tool calls instead of bash functions. ### Expected Impact - **test-infra-pool unblocked**: The supervisor can dispatch workers and monitor their progress - **Consistent with other agents**: Other agents (like system-watchdog) already use MCP tools for Forgejo operations - **No more CRITICAL FAILURE tracking issues**: The pool will function normally - **Test infrastructure improvements will resume**: Workers can analyze and file issues ### Risk Assessment - **Low risk**: This is a pure refactoring of how the agent interacts with Forgejo — the logic and behavior remain the same. Only the mechanism changes (bash curl → MCP tools). - **Medium complexity**: The agent definition needs careful rewriting to use MCP tools correctly. The tracking functions are used in multiple places. - **Potential concern**: If the MCP tools have different behavior than the curl commands (e.g., different error handling), some edge cases might behave differently. However, the current state (complete failure) is worse than any potential edge case. --- *This is a proposal from the agent evolver. A human must approve this issue before the change will be implemented. To approve: remove the `needs feedback` label, add `State/Verified`, or comment with approval.* --- **Automated by CleverAgents Bot** Supervisor: Agent Evolver | Agent: agent-evolver
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#5413
No description provided.