Skip to content

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

Open
PratikDhanave (PratikDhanave) wants to merge 4 commits into
microsoft:mainfrom
PratikDhanaveFork:feat/agenttool-arg-customization
Open

PratikDhanave (PratikDhanave) wants to merge 4 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 Outdated
@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

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

API consistency review

Result Scope
aligned public API

Changed Go contract

  • tool/agenttool.Config.ArgName (new, optional, default "query") and Config.ArgDescription (new, optional, default "input query to invoke the agent").
  • functool.Schema() now emits the configured argument name/description instead of a hardcoded "query" property.
  • functool.Call() decodes arguments into a map[string]json.RawMessage and reads the configured key, returning a JSON decoding error if that key is present with a non-string value (previously a fixed Query string struct field silently zero-valued on type mismatch).

Upstream evidence reviewed

Implementation Source Contract checked
.NET dotnet/src/Microsoft.Agents.AI/AgentExtensions.cs#L69-L91 AsAIFunction hardcodes a single strongly-typed string query parameter (description "Input query to invoke the agent.") with no name/description override — this is the baseline Go previously matched for its default "query" arg name/description.
Python python/packages/core/agent_framework/_agents.py#L657-L729 `Agent.as_tool(..., arg_name: str = "task", arg_description: str
Repo issue microsoft/agent-framework-go#1139 Issue filed by the same author explicitly scopes this PR to argument customization only, deferring session propagation (the other parity gap) to future work, and confirms the existing "query" default was already intentionally aligned with .NET.

Assessment

This is a scoped, additive parity fix explicitly tracked by #1139. Go's new ArgName/ArgDescription options mirror Python's as_tool(arg_name=..., arg_description=...) precedent while preserving the pre-existing "query" default that matches .NET's hardcoded AsAIFunction parameter, so neither existing behavior nor defaults change for callers who don't set the new fields. The stricter Call() behavior — rejecting a wrong-typed value for the configured key instead of silently defaulting to an empty query — is consistent with .NET's strongly-typed string query parameter binding (a type mismatch there also fails before invocation), and is a reasonable, non-breaking tightening given the schema declares the argument as "type": "string". Session propagation remains intentionally out of scope per the linked issue and is not required for this PR to be complete. No actionable parity issues found.

Generated by Go API Consistency Review Agent · copilot · auto · 69.5 AIC · ⌖ 8.62 AIC · ⊞ 13.9K · ◷

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 on lines +125 to +126
var query string
if raw, ok := in[t.argName]; ok {
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.
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 parity-approved Go API consistency review found no parity issues 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