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

Commitd1a09cb

Browse files
committed
fix: ignore self-reported status
1 parent9cef0df commitd1a09cb

File tree

2 files changed

+50
-17
lines changed

2 files changed

+50
-17
lines changed

‎cli/exp_mcp.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,11 @@ func (s *mcpServer) startServer(ctx context.Context, inv *serpent.Invocation, in
679679
returns.queue.Push(taskReport{
680680
link:args.Link,
681681
selfReported:true,
682-
state:codersdk.WorkspaceAppStatusState(args.State),
683-
summary:args.Summary,
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,
684687
})
685688
}),
686689
}

‎cli/exp_mcp_test.go

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -822,31 +822,27 @@ func TestExpMcpReporter(t *testing.T) {
822822
URI:"https://dev.coder.com",
823823
},
824824
},
825-
// A completed update at this point from the watcher should be discarded.
825+
// A stable update now from the watcher should be discarded, as it is a
826+
// duplicate.
826827
{
827828
event:makeStatusEvent(agentapi.StatusStable),
828829
},
829830
// Terminal becomes active again according to the screen watcher, but no
830831
// new user message. This could be the AI agent being active again, but
831832
// it could also be the user messing around. We will prefer not updating
832833
// the status so the "working" update here should be skipped.
834+
//
835+
// TODO: How do we test the no-op updates? This update is skipped
836+
// because of the logic mentioned above, but how do we prove this update
837+
// was skipped because of that and not that the next update was skipped
838+
// because it is a duplicate state? We could mock the queue?
833839
{
834840
event:makeStatusEvent(agentapi.StatusRunning),
835841
},
836842
// Agent messages are ignored.
837843
{
838844
event:makeMessageEvent(0,agentapi.RoleAgent),
839845
},
840-
// AI agent reports that it failed and URI is blank.
841-
{
842-
state:codersdk.WorkspaceAppStatusStateFailure,
843-
summary:"oops",
844-
expected:&codersdk.WorkspaceAppStatus{
845-
State:codersdk.WorkspaceAppStatusStateFailure,
846-
Message:"oops",
847-
URI:"",
848-
},
849-
},
850846
// The watcher reports the screen is active again...
851847
{
852848
event:makeStatusEvent(agentapi.StatusRunning),
@@ -857,17 +853,17 @@ func TestExpMcpReporter(t *testing.T) {
857853
event:makeMessageEvent(1,agentapi.RoleUser),
858854
expected:&codersdk.WorkspaceAppStatus{
859855
State:codersdk.WorkspaceAppStatusStateWorking,
860-
Message:"oops",
861-
URI:"",
856+
Message:"doing work",
857+
URI:"https://dev.coder.com",
862858
},
863859
},
864860
// Watcher reports stable again.
865861
{
866862
event:makeStatusEvent(agentapi.StatusStable),
867863
expected:&codersdk.WorkspaceAppStatus{
868864
State:codersdk.WorkspaceAppStatusStateIdle,
869-
Message:"oops",
870-
URI:"",
865+
Message:"doing work",
866+
URI:"https://dev.coder.com",
871867
},
872868
},
873869
},
@@ -924,6 +920,40 @@ func TestExpMcpReporter(t *testing.T) {
924920
},
925921
},
926922
},
923+
// We ignore the state from the agent and assume "working".
924+
{
925+
name:"IgnoreAgentState",
926+
// AI agent reports that it is finished but the summary says it is doing
927+
// work.
928+
tests: []test{
929+
{
930+
state:codersdk.WorkspaceAppStatusStateIdle,
931+
summary:"doing work",
932+
expected:&codersdk.WorkspaceAppStatus{
933+
State:codersdk.WorkspaceAppStatusStateWorking,
934+
Message:"doing work",
935+
},
936+
},
937+
// AI agent reports finished again, with a matching summary. We still
938+
// assume it is working.
939+
{
940+
state:codersdk.WorkspaceAppStatusStateIdle,
941+
summary:"finished",
942+
expected:&codersdk.WorkspaceAppStatus{
943+
State:codersdk.WorkspaceAppStatusStateWorking,
944+
Message:"finished",
945+
},
946+
},
947+
// Once the watcher reports stable, then we record idle.
948+
{
949+
event:makeStatusEvent(agentapi.StatusStable),
950+
expected:&codersdk.WorkspaceAppStatus{
951+
State:codersdk.WorkspaceAppStatusStateIdle,
952+
Message:"finished",
953+
},
954+
},
955+
},
956+
},
927957
}
928958

929959
for_,run:=rangeruns {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp