@@ -21,7 +21,7 @@ import (
2121
2222type 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
5352Sessions are persisted per-agent — consecutive invokes reuse the same
5453session 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
9795func (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
104102func (a * InvokeAction ) httpTimeout () time.Duration {
0 commit comments