Skip to content

generate: report tools declared but not referenced by any agent - #85

Closed
LuisMend12 wants to merge 1 commit into
extra-org:mainfrom
LuisMend12:fix/report-unreferenced-tools
Closed

generate: report tools declared but not referenced by any agent#85
LuisMend12 wants to merge 1 commit into
extra-org:mainfrom
LuisMend12:fix/report-unreferenced-tools

Conversation

@LuisMend12

Copy link
Copy Markdown
Contributor

Summary

  • Generator.generate() only looked at tool_ids collected by walking the agent graph (_collect()), so a tool declared in the top-level tools: registry but never added to any agent's tools: list was invisible in agentctl generate output — no stub (correct, nothing uses it) but no mention either. A forgotten reference looked identical to an intentional one.
  • Added SystemSpec.declared_tools, populated from the full top-level tools: registry during YAML parsing (previously this registry was only used transiently inside the parser to resolve per-agent tool references, then discarded).
  • Generator.generate() now diffs declared_tools against the referenced tool_ids and reports the difference on a new GenerateResult.ignored field.
  • agentctl generate surfaces it:
      ignore  add_new_user  (declared but not referenced by any agent)
    

Fixes #67

Test plan

  • New test tests/parsers/test_declared_tools.py — confirms the parser populates SystemSpec.declared_tools (ids + descriptions) from real YAML, using the exact repro from the issue
  • New tests in tests/generate/test_plugins_manifest.pyGenerator.generate() reports an unreferenced declared tool in result.ignored (and not in created/no stub file), and reports nothing when all declared tools are referenced
  • Ran tests/parsers, tests/generate, tests/core — all pass except 5 pre-existing failures unrelated to this change (a Windows-only path-separator assertion bug: result.created.count("plugins/plugins.toml") compares a forward-slash literal against str(Path.relative_to(...)), which yields backslashes on Windows — reproduces identically on main before this change)

Generator.generate() only looked at tool_ids collected from walking
the graph, so a tool declared under the top-level tools: registry but
never added to any agent's tools list was invisible in the output --
no stub (correct, since nothing uses it) but also no mention.

Added SystemSpec.declared_tools, populated from the full tools:
registry during parsing, and diff it against the referenced tool_ids
in Generator.generate() to report the difference as GenerateResult.ignored.
agentctl's generate command surfaces it as:

  ignore  <tool_id>  (declared but not referenced by any agent)

Fixes extra-org#67
@Asaf-prog

Copy link
Copy Markdown
Collaborator

Thanks for the contribution — the implementation direction is correct, and preserving the full top-level tool registry as declared_tools is a clear approach.

However, PR #74 is already open for the same issue and implements the same behavior, including the ignored result, CLI output, and regression coverage.

PR #74 also handles the ignored-only CLI case more accurately. In this PR, the command can currently print:

ignore add_new_user (declared but not referenced by any agent)
✓ Nothing to generate — all stubs already exist.

That summary is misleading because the ignored tool's stub does not exist by design. PR #74 uses a more accurate summary and includes an end-to-end CLI regression test.

To avoid maintaining and merging two competing implementations for #67, I think we should continue with #74 and close this PR as a duplicate.

The declared_tools naming used here is clearer, though, and is worth carrying over to #74.

Thank you again for taking the time to work on this.

@Asaf-prog Asaf-prog closed this Aug 2, 2026
@LuisMend12

Copy link
Copy Markdown
Contributor Author

Totally agree, thanks for checking — didn't see #74 was already in flight. The ignored-only summary bug you caught there is a good catch, glad it's covered. Appreciate you calling out the declared_tools naming, hope it's useful if you revisit that field later.

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.

generate: silently omits tools declared but not referenced by any agent

2 participants