Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

fix(teamhub): write an idle Task's instruction and reply as separate reports

muterC1885476e9c51
diff --git a/apps/teamhub/internal/taskexecution/attempt_reconcile.go b/apps/teamhub/internal/taskexecution/attempt_reconcile.go
index b5548b0a..e57db7fb 100644
--- a/apps/teamhub/internal/taskexecution/attempt_reconcile.go
+++ b/apps/teamhub/internal/taskexecution/attempt_reconcile.go
@@ -243,7 +243,7 @@ func settleTaskTurn(
return err
}
status, reason := "idle", "run_succeeded"
- report := ""
+ var reports []string
if len(pending) > 0 {
status, reason = "waiting_for_approval", "pending_approval"
} else {
@@ -256,9 +256,11 @@ func settleTaskTurn(
if reply = strings.TrimSpace(reply); reply == "" {
reply = "(no reply)"
}
- report = "Task " + snapshot.Title + " (" + input.TaskID + ") is idle. " + taskDoneReminder(input.TaskID) + "\n" + reply
+ // The Meta reads what to do, then the AlterEgo's own words as their
+ // own report, the one a live call tells as the Task's latest.
+ reports = []string{"Task " + snapshot.Title + " (" + input.TaskID + ") is idle. " + taskDoneReminder(input.TaskID), reply}
}
- return settleTaskStatus(ctx, queries, lease, snapshot, input, status, reason, report, map[string]any{
+ return settleTaskStatus(ctx, queries, lease, snapshot, input, status, reason, reports, map[string]any{
"attempt_id": attempt.ID, "input_revision": attempt.CurrentInputRevision,
"agent_run_ref": lastRun.AgentRunRef, "pending_approvals": len(pending),
})
@@ -301,13 +303,13 @@ func failTaskAttempt(
return err
}
report := "Task " + snapshot.Title + " (" + input.TaskID + ") failed: " + truncateRunes(failure, taskReportFailureMaxRunes)
- return settleTaskStatus(ctx, queries, lease, snapshot, input, "failed", stopReason, report, map[string]any{
+ return settleTaskStatus(ctx, queries, lease, snapshot, input, "failed", stopReason, []string{report}, map[string]any{
"attempt_id": attempt.ID, "attempt_number": attempt.AttemptNumber, "stop_reason_code": stopReason,
})
}
// settleTaskStatus moves a running Task to the state its ended turn
-// produced and, when report is set, writes it to the Task's hidden callback
+// produced and writes its reports, in order, to the Task's hidden callback
// stream, which wakes the coordinating Meta.
func settleTaskStatus(
ctx context.Context,
@@ -315,7 +317,8 @@ func settleTaskStatus(
lease store.WorkItem,
snapshot store.LockTaskExecutionSnapshotRow,
input WorkerTransitionInput,
- status, reason, report string,
+ status, reason string,
+ reports []string,
payload map[string]any,
) error {
nextRevision := input.ExpectedExecutionRevision + 1
@@ -337,7 +340,7 @@ func settleTaskStatus(
} else if err != nil {
return err
}
- if report != "" {
+ for _, report := range reports {
if err := appendTaskReport(ctx, queries, snapshot, input.ExecutionGeneration, report); err != nil {
return err
}
diff --git a/apps/teamhub/tests/integration/task_delegation_lifecycle_test.go b/apps/teamhub/tests/integration/task_delegation_lifecycle_test.go
index d746899f..cac9b327 100644
--- a/apps/teamhub/tests/integration/task_delegation_lifecycle_test.go
+++ b/apps/teamhub/tests/integration/task_delegation_lifecycle_test.go
@@ -180,14 +180,16 @@ func TestDelegatedTaskTurnOutcomesAndReports(t *testing.T) {
reports := taskReports(t, env, created.TaskID)
want := "Task Summarize notes (" + created.TaskID + ") is idle. If it is done, deliver it to the user with teamhub message card: a title, " +
"a one-line result, and its files from ./playground/" + created.TaskID + "/ with --attach; then say in one " +
- "ordinary message what the user should add or check, if anything.\nHere is the summary: all good."
- if len(reports) != 1 || reports[0] != want {
+ "ordinary message what the user should add or check, if anything."
+ // What to do and the AlterEgo's own words are separate reports, so a
+ // live call tells the Task's latest report without the Meta's part.
+ if len(reports) != 2 || reports[0] != want || reports[1] != "Here is the summary: all good." {
t.Fatalf("reports=%q want %q", reports, want)
}
- // The report wakes the origin Room's Meta through the Task callback stream.
+ // The reports wake the origin Room's Meta through the Task callback stream.
if got := countRows(t, env, `SELECT count(*) FROM task_meta_callbacks callback
WHERE callback.task_id=$1 AND callback.coordinator_actor_id='actor_acme_official'
- AND callback.coordinator_context_key=$2 AND callback.through_seq=1`,
+ AND callback.coordinator_context_key=$2 AND callback.through_seq=2`,
created.TaskID, `["meta","`+acmeOfficialAgentManagementID+`","room","`+roomID+`"]`); got != 1 {
t.Fatalf("Meta callback cursor rows=%d want=1", got)
}
@@ -209,7 +211,7 @@ func TestDelegatedTaskTurnOutcomesAndReports(t *testing.T) {
insertAlterEgoLocalRun(t, env, created.TaskID, "run-outcome-empty", " ")
worker.endTurn(effectID, "run-outcome-empty", "succeeded", "")
worker.advance()
- if reports := taskReports(t, env, created.TaskID); len(reports) != 1 || !strings.HasSuffix(reports[0], "with --attach.\n(no reply)") {
+ if reports := taskReports(t, env, created.TaskID); len(reports) != 2 || reports[1] != "(no reply)" {
t.Fatalf("reports=%q", reports)
}
})