Skip to content

Commit f92eda7

Browse files
committed
Make remote the default
Signed-off-by: trangevi <trangevi@microsoft.com>
1 parent 2f68ac5 commit f92eda7

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

cli/azd/extensions/azure.ai.agents/internal/cmd/invoke.go

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121

2222
type invokeFlags struct {
2323
message string
24-
remote bool
24+
local bool
2525
name string
2626
port int
2727
timeout int
@@ -41,28 +41,27 @@ func newInvokeCommand() *cobra.Command {
4141
Short: "Send a message to your agent.",
4242
Long: `Send a message to your agent.
4343
44-
With one argument the value is treated as the message and the agent is
45-
invoked locally on localhost:8088.
44+
By default the agent is invoked remotely on Foundry. When a single
45+
argument is provided it is treated as the message and the agent name
46+
is auto-detected from azure.yaml. With two arguments the first is the
47+
agent name and the second is the message.
4648
47-
With two arguments the first is the agent name and the second is the
48-
message. Providing a name implies --remote and invokes on Foundry.
49-
50-
Use --remote to invoke on Foundry without specifying an agent name
51-
(auto-detected from azure.yaml).
49+
Use --local to target a locally running agent (started via 'azd ai agent run')
50+
instead of Foundry.
5251
5352
Sessions are persisted per-agent — consecutive invokes reuse the same
5453
session automatically. Pass --new-session to force a reset.`,
55-
Example: ` # Invoke locally (agent must be running via 'azd ai agent run')
54+
Example: ` # Invoke the remote agent on Foundry (auto-detects agent from azure.yaml)
5655
azd ai agent invoke "Hello!"
5756
58-
# Invoke the remote agent on Foundry (auto-detects agent from azure.yaml)
59-
azd ai agent invoke --remote "Hello!"
60-
6157
# Invoke a specific remote agent by name
6258
azd ai agent invoke my-agent "Hello!"
6359
60+
# Invoke locally (agent must be running via 'azd ai agent run')
61+
azd ai agent invoke --local "Hello!"
62+
6463
# Start a new session (discard conversation history)
65-
azd ai agent invoke --remote --new-session "Hello!"`,
64+
azd ai agent invoke --new-session "Hello!"`,
6665
Args: cobra.RangeArgs(1, 2),
6766
RunE: func(cmd *cobra.Command, args []string) error {
6867
ctx := azdext.WithAccessToken(cmd.Context())
@@ -75,17 +74,16 @@ session automatically. Pass --new-session to force a reset.`,
7574
flags.message = args[0]
7675
}
7776

78-
// Providing a name implies --remote
79-
if flags.name != "" {
80-
flags.remote = true
77+
if flags.name != "" && flags.local {
78+
return fmt.Errorf("cannot use --local with a named agent; named agents are always invoked remotely on Foundry")
8179
}
8280

8381
action := &InvokeAction{flags: flags}
8482
return action.Run(ctx)
8583
},
8684
}
8785

88-
cmd.Flags().BoolVarP(&flags.remote, "remote", "r", false, "Invoke on Foundry instead of localhost")
86+
cmd.Flags().BoolVarP(&flags.local, "local", "l", false, "Invoke on localhost instead of Foundry")
8987
cmd.Flags().IntVar(&flags.port, "port", DefaultPort, "Local server port")
9088
cmd.Flags().IntVarP(&flags.timeout, "timeout", "t", 120, "Request timeout in seconds (0 for no timeout)")
9189
cmd.Flags().StringVarP(&flags.session, "session", "s", "", "Explicit session ID override")
@@ -95,10 +93,10 @@ session automatically. Pass --new-session to force a reset.`,
9593
}
9694

9795
func (a *InvokeAction) Run(ctx context.Context) error {
98-
if a.flags.remote {
99-
return a.invokeRemote(ctx)
96+
if a.flags.local {
97+
return a.invokeLocal(ctx)
10098
}
101-
return a.invokeLocal(ctx)
99+
return a.invokeRemote(ctx)
102100
}
103101

104102
func (a *InvokeAction) httpTimeout() time.Duration {

cli/azd/extensions/azure.ai.agents/internal/cmd/run.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ agent service in azure.yaml. If not set, it is auto-detected from the
4343
project type. Use --start-command to override both.
4444
4545
Use a separate terminal to invoke the running agent:
46-
azd ai agent invoke "Hello!"`,
46+
azd ai agent invoke --local "Hello!"`,
4747
Example: ` # Start the agent in the current directory
4848
azd ai agent run
4949
@@ -146,7 +146,7 @@ func runRun(ctx context.Context, flags *runFlags) error {
146146
url := fmt.Sprintf("http://localhost:%d", flags.port)
147147
fmt.Println()
148148
fmt.Println("After startup, in another terminal, try:")
149-
fmt.Printf(" azd ai agent invoke \"Hello!\"\n\n")
149+
fmt.Printf(" azd ai agent invoke --local \"Hello!\"\n\n")
150150
fmt.Printf("Starting agent on %s (Ctrl+C to stop)\n\n", url)
151151

152152
// Create command with stdout/stderr piped to terminal

0 commit comments

Comments
 (0)