Kiro icon indicating copy to clipboard operation
Kiro copied to clipboard

When delegating to a subagent, the delegated agent doesn't honor the agent definition.

Open trichards-symplr opened this issue 9 months ago • 3 comments

Before opening, please confirm:

Operating System

win32 but I'm executing using WSL

Kiro Version

0.9.40

Bug Description

My subagent specifies the tools:

tools: [controlPwshProcess, getProcessOutput]

Kiro reports that it can't control what tools the subagent actually uses internally. The agent definition specifies tools: [controlPwshProcess, getProcessOutput], but when invoked as a subagent it may still fall back to executePwsh.

We solved this by not delegating to the subagent, but instead forcing kiro to follow the agent workflow itself directly using controlPwshProcess and getProcessOutput.

The bug is, subagents should follow it's agent definition to the letter without deviating from the agent specification.

Steps to Reproduce

Asking Kiro to follow the subagent when executing any cargo command, when the agent hands off to the subtask, the agent will fall back to executePwsh even though the agent definition specifically says not to do so. This causes the agent execution to fail.

This is the agent definition:

---
name: cargo-runner
description: Runs cargo commands as background processes using controlPwshProcess, monitors their completion, and returns structured analysis. MUST use controlPwshProcess - never executePwsh.
tools: [controlPwshProcess, getProcessOutput]
---

You are a cargo command runner agent. You execute cargo commands as background processes and return structured output.

## CRITICAL RULES — READ FIRST

- You MUST use `controlPwshProcess` with action `start` to run commands. This is NON-NEGOTIABLE.
- You MUST NOT use `executePwsh`. You do not have access to it. It does not exist for you.
- You MUST NOT use any tool other than `controlPwshProcess` and `getProcessOutput`.
- You MUST NOT use sleep, Start-Sleep, timeout, or any delay commands.
- If you try to use executePwsh, you have FAILED your task.

## Exact Workflow — Follow These Steps In Order

### Step 1: Start the command
Call `controlPwshProcess` with these exact parameters:
- action: "start"
- command: the cargo command (e.g. "cargo test")
- cwd: null (uses workspace root)

Save the `processId` from the response.

### Step 2: Poll for completion
Call `getProcessOutput` with:
- processId: the processId from step 1
- lines: 30

Check the output for completion indicators:
- "test result:" means tests finished
- "Finished" means build/check finished
- "error[E" means compilation failed
- "could not compile" means compilation failed

If none of these appear, call `getProcessOutput` again with lines: 30.
Repeat up to 10 times maximum.

### Step 3: Read full output
Once complete, call `getProcessOutput` with:
- processId: the processId from step 1
- lines: 200

### Step 4: Stop the process
Call `controlPwshProcess` with:
- action: "stop"
- processId: the processId from step 1

### Step 5: Return results
Return in this exact format:

```
CARGO RESULT: [SUCCESS|FAILURE]
Command: <command>

Errors: <count>
<list each error>

Warnings: <count>
<list each warning>

Test Failures: <count>
<list each failed test>

Summary: <one line>
```

## Reminders
- ONLY use controlPwshProcess and getProcessOutput
- NEVER use executePwsh
- NEVER use sleep or delays
- Do not fix errors — only report them

Expected Behavior

Kiro will follow subagent definition and execute as described in the subagent without falling back to executePwsh

Conversation ID

56b6fd8b-5934-44a8-807c-205a654d7597 27fbb475-3738-4b8f-a815-45709036d462 584bd7e0-1d93-43bd-858a-c4cad293b64f f75dc43c-4b8b-4daf-b2bc-be7524610a18 b1469813-8687-4939-865d-90eb10844543

Additional Context

No response

trichards-symplr avatar Feb 15 '26 05:02 trichards-symplr

🤖 Potential Duplicate Detected

This issue appears to be similar to:

What happens next?

  • ⏰ This issue will be automatically closed in 3 days
  • 🏷️ If this is not a duplicate, you can prevent automatic closure by adding a comment or reacting with 👎 to this message.
  • 💬 Comment on the original issue if you have additional information

Why is this marked as duplicate? Both issues report AI agents not following specified instructions - the new issue describes subagents ignoring tool restrictions in agent definitions, while #4814 reports AI not following instructions generally. Same core problem of instruction adherence failure.

github-actions[bot] avatar Feb 15 '26 05:02 github-actions[bot]

This issue has been automatically closed as it appears to be a duplicate of #4814.

If you believe this is incorrect, please comment on this issue and a maintainer will review it.

github-actions[bot] avatar Feb 19 '26 00:02 github-actions[bot]

Thank you for your feedback! 🙏

The duplicate label has been removed and this issue has been sent back for maintainer review.

A maintainer will review this issue shortly.

github-actions[bot] avatar Feb 20 '26 15:02 github-actions[bot]