Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit45a5685

Browse files
committed
Only override agent status if agent api is configured
1 parentd1a09cb commit45a5685

File tree

2 files changed

+45
-11
lines changed

2 files changed

+45
-11
lines changed

‎cli/exp_mcp.go‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -674,16 +674,22 @@ func (s *mcpServer) startServer(ctx context.Context, inv *serpent.Invocation, in
674674
}
675675

676676
// Add tool dependencies.
677+
hasAgentAPI:=s.aiAgentAPIClient!=nil
677678
toolOpts:= []func(*toolsdk.Deps){
678679
toolsdk.WithTaskReporter(func(args toolsdk.ReportTaskArgs)error {
680+
// The agent does not reliably report its status correctly. If AgentAPI
681+
// is enabled, we will always set the status to "working" when we get an
682+
// MCP message, and rely on the screen watcher to eventually catch the
683+
// idle state.
684+
state:=codersdk.WorkspaceAppStatusStateWorking
685+
if!hasAgentAPI {
686+
state=codersdk.WorkspaceAppStatusState(args.State)
687+
}
679688
returns.queue.Push(taskReport{
680689
link:args.Link,
681690
selfReported:true,
682-
// The agent does not reliably report its status correctly. We will
683-
// always set the status to "working" when we get an MCP message, and
684-
// rely on the screen watcher to eventually catch the idle state.
685-
state:codersdk.WorkspaceAppStatusStateWorking,
686-
summary:args.Summary,
691+
state:state,
692+
summary:args.Summary,
687693
})
688694
}),
689695
}

‎cli/exp_mcp_test.go‎

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -793,8 +793,9 @@ func TestExpMcpReporter(t *testing.T) {
793793
}
794794

795795
runs:= []struct {
796-
namestring
797-
tests []test
796+
namestring
797+
tests []test
798+
disableAgentAPIbool
798799
}{
799800
// In this run the AI agent starts with a state change but forgets to update
800801
// that it finished.
@@ -954,6 +955,29 @@ func TestExpMcpReporter(t *testing.T) {
954955
},
955956
},
956957
},
958+
// When AgentAPI is not being used, we accept agent state updates as-is.
959+
{
960+
name:"KeepAgentState",
961+
tests: []test{
962+
{
963+
state:codersdk.WorkspaceAppStatusStateWorking,
964+
summary:"doing work",
965+
expected:&codersdk.WorkspaceAppStatus{
966+
State:codersdk.WorkspaceAppStatusStateWorking,
967+
Message:"doing work",
968+
},
969+
},
970+
{
971+
state:codersdk.WorkspaceAppStatusStateIdle,
972+
summary:"finished",
973+
expected:&codersdk.WorkspaceAppStatus{
974+
State:codersdk.WorkspaceAppStatusStateIdle,
975+
Message:"finished",
976+
},
977+
},
978+
},
979+
disableAgentAPI:true,
980+
},
957981
}
958982

959983
for_,run:=rangeruns {
@@ -1019,15 +1043,19 @@ func TestExpMcpReporter(t *testing.T) {
10191043
}
10201044
}
10211045

1022-
inv,_:=clitest.New(t,
1046+
args:=[]string{
10231047
"exp","mcp","server",
1024-
// We need the agent credentials, AI AgentAPI url, and a slug for reporting.
1048+
// We need the agent credentials, AI AgentAPI url (if not
1049+
// disabled), and a slug for reporting.
10251050
"--agent-url",client.URL.String(),
10261051
"--agent-token",r.AgentToken,
10271052
"--app-status-slug","vscode",
1028-
"--ai-agentapi-url",aiAgentAPIURL,
10291053
"--allowed-tools=coder_report_task",
1030-
)
1054+
}
1055+
if!run.disableAgentAPI {
1056+
args=append(args,"--ai-agentapi-url",aiAgentAPIURL)
1057+
}
1058+
inv,_:=clitest.New(t,args...)
10311059
inv=inv.WithContext(ctx)
10321060

10331061
pty:=ptytest.New(t)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp