Skip to content

feat(agents): embedders pick each agent's tools and sub-agent finish tools - #1787

Merged
ian-at-strix merged 3 commits into
mainfrom
refactor/finish-tool-names
Nov 19, 2026
Merged

ian-at-strix merged 3 commits into
mainfrom
refactor/finish-tool-names

Conversation

@ian-at-strix

@ian-at-strix ian-at-strix commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Lets strix-pro give each PR-review agent type only its own tools, ending with its own finish tool (investigator_finish, validator_finish, reporter_finish). No behavior change when unused.

Change What
select_tools on run_strix_scan Called with is_root, the agent's skills and its default tools; returns the tools to build that agent with
FINISH_TOOL_KEY on a sub-agent's spawn context Its first message, turn-limit notices, wrap-up directives and recovery nudge name that tool instead of agent_finish
_LIFECYCLE_TOOLS One table of every tool that ends a run and the result key it sets (replaces the if/elif chain); lists strix-pro's finish tools
finish_tool_name(context) (refactor) One lookup of an agent's finish tool, root or sub-agent

@arcanist

arcanist Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Ready to merge Re-run Arcanist review

PR summary

Embedders could not choose each agent's tools or give a sub-agent its own finish-tool instructions. They now have a tool selector and a shared lifecycle table for the review finish tools, while callers that use neither keep the previous behavior. The custom finish-tool value is never stored on a spawned or resumed child's context, so its messages still request agent_finish and an agent given only its custom finish tool receives an unusable completion instruction. The selector also runs before sandbox capabilities are added, so excluded shell and filesystem tools still reach the model and the promised per-agent restriction is not enforced.

Review history (4)
🔴 High blast radius. If this breaks (1):
  1. Every agent in a customized embedder can use excluded shell and filesystem tools because they're added after select_tools runs.
Flow diagram
%%{init: {"theme": "neutral"}}%%
flowchart TD
  n0["Scan runner"]
  n1["Build agent"]
  n0 --> n1
  n2{"Selector supplied?"}
  n1 --> n2
  n3["Choose tools"]
  n2 -->|"Yes"| n3
  n4["Return chosen tools"]
  n3 --> n4
  n5["Agent is ready"]
  n4 --> n5
  n2 -->|"Keep default tools"| n5
Loading
✅ Ruled out (3)
  • Could the lifecycle refactor stop recognizing the original finish tools?
    No, each original finish tool keeps its previous completion key, and the same completion check consumes the table.
  • Could existing scans change when the new finish-tool setting is unused?
    No, an unset sub-agent value still uses the original completion tool, and a root still uses its configured scan completion tool.
  • Could a custom finish tool bypass completion or parent notification?
    No, successful custom finishes map to the same completion result, and terminal exit still notifies the parent.

@ian-at-strix
ian-at-strix added this pull request to stack #1789 November 19, 2026 15:24
@ian-at-strix
ian-at-strix force-pushed the refactor/finish-tool-names branch from dc43f93 to c86da3a Compare November 19, 2026 15:27
@ian-at-strix ian-at-strix changed the title refactor(agents): look up lifecycle tools in a table; a sub-agent's spawn context can name its finish tool feat(agents): let embedders pick each agent's tools Nov 19, 2026
Comment thread strix/agents/factory.py Resolved
@ian-at-strix
ian-at-strix marked this pull request as ready for review November 19, 2026 16:37
@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with a non-blocking fix needed for custom finish-tool instructions after resume.

Findings

  1. P2 Resumed children forget finish tools ▶
Fix with agent prompt
### Issue 1
strix/core/hooks.py:155-156
**Resumed children forget finish tools.** A child's custom `FINISH_TOOL_KEY` survives a fresh spawn because its context copies `parent_ctx`, but it is never saved with the child. On resume, `respawn_subagents` rebuilds every child from the fresh root context, which lacks this key. This lookup then returns `agent_finish`, so warnings and recovery messages direct the child to a tool that `select_tools` may have removed in favor of `validator_finish` or another custom finish tool.

Save the name with each child's metadata and restore it into the child's context before restarting it.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR lets embedders choose each agent's tools and give child agents their own finish tools.

  • Callers can choose which tools each scan agent receives.
  • Child agents can finish with the tool chosen for their role.

One non-blocking issue remains: resumed children lose their custom finish-tool name.

Reviews (2) · Last reviewed commit: "refactor(agents): one helper names the t..." · Reviewed by Greptile

@ian-at-strix ian-at-strix changed the title feat(agents): let embedders pick each agent's tools feat(agents): embedders pick each agent's tools and sub-agent finish tools Nov 19, 2026
Comment thread strix/core/execution.py Resolved
@ian-at-strix
ian-at-strix removed this pull request from stack #1789 November 19, 2026 17:11
@ian-at-strix
ian-at-strix requested a review from 0xallam November 19, 2026 17:15
@ian-at-strix
ian-at-strix merged commit a27bf89 into main Nov 19, 2026
11 of 15 checks passed
Comment thread strix/core/hooks.py
Comment on lines +155 to +156
def subagent_finish_tool(context: dict[str, Any]) -> str:
return str(context.get(FINISH_TOOL_KEY) or "agent_finish")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Resumed children forget finish tools. A child's custom FINISH_TOOL_KEY survives a fresh spawn because its context copies parent_ctx, but it is never saved with the child. On resume, respawn_subagents rebuilds every child from the fresh root context, which lacks this key. This lookup then returns agent_finish, so warnings and recovery messages direct the child to a tool that select_tools may have removed in favor of validator_finish or another custom finish tool.

Save the name with each child's metadata and restore it into the child's context before restarting it.

Prompt To Fix With AI
This is a comment left during a code review.
Path: strix/core/hooks.py
Line: 155-156

Comment:
**Resumed children forget finish tools.** A child's custom `FINISH_TOOL_KEY` survives a fresh spawn because its context copies `parent_ctx`, but it is never saved with the child. On resume, `respawn_subagents` rebuilds every child from the fresh root context, which lacks this key. This lookup then returns `agent_finish`, so warnings and recovery messages direct the child to a tool that `select_tools` may have removed in favor of `validator_finish` or another custom finish tool.

Save the name with each child's metadata and restore it into the child's context before restarting it.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants