Skip to content

[dotnet-port-api] Add agent-as-tool argument name/description customization - #1157

Merged
Quim Muntal (qmuntal) merged 5 commits into
microsoft:mainfrom
PratikDhanaveFork:feat/agenttool-arg-customization
Oct 30, 2026
Merged

Quim Muntal (qmuntal) merged 5 commits into
microsoft:mainfrom
PratikDhanaveFork:feat/agenttool-arg-customization

Conversation

@PratikDhanave

Copy link
Copy Markdown
Contributor

Partial implementation of #1139.

agenttool hardcoded a single query string argument with a fixed description. Add ArgName and ArgDescription config options so a caller can rename/re-describe the argument the model sees — mirroring the .NET/Python as-tool argument options.

Change

  • Config.ArgName (default "query") and Config.ArgDescription (default "input query to invoke the agent").
  • Schema() emits the configured argument name/description; Call() reads the configured key (decoding into a map rather than a fixed struct field).
  • Defaults are unchanged, so existing behavior and tests are unaffected.

Scoped to the argument customization; session propagation (the other half of #1139) is left for the design discussion there, since obtaining the caller session at Call time needs a mechanism the tool interface does not currently expose.

Test

  • TestNew_CustomArgNameAndDescription: a custom ArgName:"task" is reflected in the schema (and the default query is gone), and Call with {"task":...} forwards the value to the agent. Fails to build before the change (fields absent), passes after.

agenttool hardcoded a single "query" string argument. Add ArgName and
ArgDescription config options (defaulting to "query" / "input query to
invoke the agent") so callers can rename/re-describe the argument the model
sees, mirroring the .NET/Python as-tool argument options. The schema and Call
now use the configured name.

Partial for microsoft#1139 (session propagation is left for the design discussion on
that issue).
Copilot AI lite review requested due to automatic review settings September 22, 2026 05:24
@github-actions github-actions Bot added area:tool Changes files in the tool area size:medium At most 100 changed lines across at most 5 files labels Sep 22, 2026

Copilot AI left a comment

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.

Copilot review overview

🟡 Changes recommended

Invalid non-string argument values are silently converted into blank queries instead of returning decoding errors.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds configurable argument names and descriptions to agenttool, preserving existing defaults.

Changes:

  • Added ArgName and ArgDescription configuration.
  • Updated schema generation and argument forwarding.
  • Added custom-argument tests.
File Description
tool/​agenttool/​agenttool.go Implements configurable argument metadata and invocation.
tool/​agenttool/​agenttool_test.go Tests custom schema and argument forwarding.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tool/agenttool/agenttool.go Resolved
@github-actions github-actions Bot added kind:code Changes production behavior or code kind:tests Changes tests, fixtures, or test infrastructure labels Sep 22, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added parity-approved Go API consistency review found no parity issues public-api-change Pull Request changes public APIs labels Sep 22, 2026
@github-actions

This comment has been minimized.

@qmuntal Quim Muntal (qmuntal) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@github-actions github-actions Bot added size:large At most 300 changed lines across at most 10 files and removed size:medium At most 100 changed lines across at most 5 files labels Oct 8, 2026
@qmuntal
Quim Muntal (qmuntal) requested a balanced review from Copilot October 8, 2026 05:29
@github-actions

This comment has been minimized.

Copilot AI left a comment

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.

🟡 Changes recommended

Exact map lookup introduces an undocumented case-sensitivity compatibility regression.

3 open findings

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Comment thread tool/agenttool/agenttool.go Outdated
Comment on lines +125 to +126
var query string
if raw, ok := in[t.argName]; ok {
Comment thread tool/agenttool/agenttool.go Outdated
Comment on lines +35 to +37
// ArgName overrides the name of the single string argument the tool exposes
// to the model. Defaults to "query". Mirrors the .NET/Python as-tool
// argument-name option.
- Call() now matches the configured argument name case-insensitively
  (preferring an exact match), restoring encoding/json's default behavior so
  existing callers using e.g. "Query"/"QUERY" still reach the agent instead
  of getting a blank query.
- Drop the .NET/Python porting note from the exported Config.ArgName doc; keep
  the exported API documentation focused on Go behavior.
- Add TestCall_CaseInsensitiveArgName.
@github-actions

Copy link
Copy Markdown
Contributor

API consistency review

Result Scope
unable to determine public API, user-visible behavior

Changed Go contract

agenttool.Config gains ArgName (default "query") and ArgDescription (default "input query to invoke the agent"). Schema() and Call() now use the configured argument name. Call() also matches the key case-insensitively and returns a JSON error if the value is not a string.

Upstream evidence reviewed

I could not complete the upstream comparison. Code search was rate-limited (429). The Python _agents.py file is about 195 KB and was returned as a single line, so I could not read the as_tool argument options. I also couldn't confirm the .NET AsAIFunction and AIFunctionFactoryOptions surface.

Assessment

The Go defaults are unchanged and match the existing .NET-aligned schema, so I found no confirmed divergence. I could not verify the following against upstream:

  • the argument option names and defaults, including the Python as_tool arg_name and arg_description defaults;
  • whether .NET exposes an equivalent option;
  • whether case-insensitive key matching is expected.

Maintainers should check these manually. I removed parity-approved until that is done. public-api-change stays because exported config fields were added.

Generated by Go API Consistency Review Agent · copilot · auto · 27.5 AIC · ⌖ 0.616 AIC · ⊞ 4.9K · ◷

@github-actions github-actions Bot removed the parity-approved Go API consistency review found no parity issues label Oct 30, 2026
@qmuntal
Quim Muntal (qmuntal) added this pull request to the merge queue Oct 30, 2026
Merged via the queue into microsoft:main with commit 66efd5f Oct 30, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:tool Changes files in the tool area kind:code Changes production behavior or code kind:tests Changes tests, fixtures, or test infrastructure public-api-change Pull Request changes public APIs size:large At most 300 changed lines across at most 10 files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants