Skip to content

Commit 4b4786a

Browse files
committed
feat: add idle AI agent status
"Idle" is more accurate than "complete" since: 1. AgentAPI only knows if the screen is active; it has no way of knowing if the task is complete. 2. The LLM might be done with its current prompt, but that does not mean the task is complete either (it likely needs refinement). The "complete" state will be reserved for future definition.
1 parent 82c14e0 commit 4b4786a

File tree

17 files changed

+50
-12
lines changed

17 files changed

+50
-12
lines changed

cli/exp_mcp.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,10 +585,10 @@ func (s *mcpServer) startWatcher(ctx context.Context, inv *serpent.Invocation) {
585585
case event := <-eventsCh:
586586
switch ev := event.(type) {
587587
case agentapi.EventStatusChange:
588-
// If the screen is stable, assume complete.
588+
// If the screen is stable, report idle.
589589
state := codersdk.WorkspaceAppStatusStateWorking
590590
if ev.Status == agentapi.StatusStable {
591-
state = codersdk.WorkspaceAppStatusStateComplete
591+
state = codersdk.WorkspaceAppStatusStateIdle
592592
}
593593
err := s.queue.Push(taskReport{
594594
state: state,

cli/exp_mcp_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ func TestExpMcpReporter(t *testing.T) {
900900
{
901901
event: makeStatusEvent(agentapi.StatusStable),
902902
expected: &codersdk.WorkspaceAppStatus{
903-
State: codersdk.WorkspaceAppStatusStateComplete,
903+
State: codersdk.WorkspaceAppStatusStateIdle,
904904
Message: "doing work",
905905
URI: "https://dev.coder.com",
906906
},
@@ -948,7 +948,7 @@ func TestExpMcpReporter(t *testing.T) {
948948
{
949949
event: makeStatusEvent(agentapi.StatusStable),
950950
expected: &codersdk.WorkspaceAppStatus{
951-
State: codersdk.WorkspaceAppStatusStateComplete,
951+
State: codersdk.WorkspaceAppStatusStateIdle,
952952
Message: "oops",
953953
URI: "",
954954
},

coderd/apidoc/docs.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dump.sql

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-- It is not possible to delete enum values.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TYPE workspace_app_status_state ADD VALUE IF NOT EXISTS 'idle';

coderd/database/models.go

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/workspaceagents.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,10 @@ func (api *API) patchWorkspaceAgentAppStatus(rw http.ResponseWriter, r *http.Req
359359
}
360360

361361
switch req.State {
362-
case codersdk.WorkspaceAppStatusStateComplete, codersdk.WorkspaceAppStatusStateFailure, codersdk.WorkspaceAppStatusStateWorking: // valid states
362+
case codersdk.WorkspaceAppStatusStateComplete,
363+
codersdk.WorkspaceAppStatusStateFailure,
364+
codersdk.WorkspaceAppStatusStateWorking,
365+
codersdk.WorkspaceAppStatusStateIdle: // valid states
363366
default:
364367
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
365368
Message: "Invalid state provided.",

codersdk/toolsdk/toolsdk.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ Bad Tasks
191191
Use the "state" field to indicate your progress. Periodically report
192192
progress with state "working" to keep the user updated. It is not possible to send too many updates!
193193
194-
ONLY report a "complete" or "failure" state if you have FULLY completed the task.
194+
ONLY report a "idle" or "failure" state if you have FULLY completed the task.
195195
`,
196196
Schema: aisdk.Schema{
197197
Properties: map[string]any{
@@ -205,10 +205,10 @@ ONLY report a "complete" or "failure" state if you have FULLY completed the task
205205
},
206206
"state": map[string]any{
207207
"type": "string",
208-
"description": "The state of your task. This can be one of the following: working, complete, or failure. Select the state that best represents your current progress.",
208+
"description": "The state of your task. This can be one of the following: working, idle, or failure. Select the state that best represents your current progress.",
209209
"enum": []string{
210210
string(codersdk.WorkspaceAppStatusStateWorking),
211-
string(codersdk.WorkspaceAppStatusStateComplete),
211+
string(codersdk.WorkspaceAppStatusStateIdle),
212212
string(codersdk.WorkspaceAppStatusStateFailure),
213213
},
214214
},

codersdk/workspaceapps.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type WorkspaceAppStatusState string
1919

2020
const (
2121
WorkspaceAppStatusStateWorking WorkspaceAppStatusState = "working"
22+
WorkspaceAppStatusStateIdle WorkspaceAppStatusState = "idle"
2223
WorkspaceAppStatusStateComplete WorkspaceAppStatusState = "complete"
2324
WorkspaceAppStatusStateFailure WorkspaceAppStatusState = "failure"
2425
)

docs/reference/api/builds.md

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/api/schemas.md

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/api/templates.md

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/api/typesGenerated.ts

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/modules/apps/AppStatusStateIcon.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
CircleAlertIcon,
66
CircleCheckIcon,
77
HourglassIcon,
8+
SquareIcon,
89
TriangleAlertIcon,
910
} from "lucide-react";
1011
import type { FC } from "react";
@@ -26,6 +27,10 @@ export const AppStatusStateIcon: FC<AppStatusStateIconProps> = ({
2627
const className = cn(["size-4 shrink-0", customClassName]);
2728

2829
switch (state) {
30+
case "idle":
31+
return (
32+
<SquareIcon className={cn(["text-content-secondary", className])} />
33+
);
2934
case "complete":
3035
return (
3136
<CircleCheckIcon className={cn(["text-content-success", className])} />

site/src/modules/workspaces/WorkspaceAppStatus/WorkspaceAppStatus.stories.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ export const Working: Story = {
3939
},
4040
};
4141

42+
export const Idle: Story = {
43+
args: {
44+
status: {
45+
...MockWorkspaceAppStatus,
46+
state: "idle",
47+
message: "Done for now",
48+
},
49+
},
50+
};
51+
4252
export const LongMessage: Story = {
4353
args: {
4454
status: {

0 commit comments

Comments
 (0)