Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/responder-approval-followups.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eve": patch
---

Preserve normal follow-up messages while an approval with responder authorization remains pending.
25 changes: 24 additions & 1 deletion packages/eve/src/harness/approval-delivery-coordinator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest";
import type { SessionAuthContext } from "#channel/types.js";
import { settleDirectApprovalResponse } from "#harness/approval-candidates.js";
import { coordinateApprovalDelivery } from "#harness/approval-delivery-coordinator.js";
import { appendPendingInputBatch } from "#harness/pending-input-batches.js";
import { appendPendingInputBatch, getPendingInputBatches } from "#harness/pending-input-batches.js";
import type { HarnessSession } from "#harness/types.js";
import type { InputRequest } from "#shared/input.js";

Expand Down Expand Up @@ -82,4 +82,27 @@ describe("coordinateApprovalDelivery", () => {
{ optionId: "cancel", requestId: request.requestId },
]);
});

it("forwards an unrelated message while a response-authorized approval remains pending", async () => {
const messageAuth: SessionAuthContext = { ...responder, principalId: "user-2" };
const result = await coordinateApprovalDelivery({
now: 100,
session: parkedSession(),
stepInput: {
message: "What else can you help with?",
messageAuth,
},
tools: new Map(),
});

expect(result.kind).toBe("continue");
expect(result.feedback).toEqual([]);
expect(result.stepInput?.message).toBe("What else can you help with?");
expect(result.stepInput?.messageAuth).toEqual(messageAuth);
expect(
getPendingInputBatches(result.session.state).flatMap((batch) =>
batch.requests.map((pending) => pending.requestId),
),
).toEqual([request.requestId]);
});
});
17 changes: 0 additions & 17 deletions packages/eve/src/harness/approval-delivery-coordinator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import type { HarnessSession, HarnessToolMap, StepInput } from "#harness/types.j
import type { InputRequest } from "#shared/input.js";

const UNAUTHENTICATED_APPROVAL_FEEDBACK = "Authentication is required to respond to this approval.";
const TEXT_APPROVAL_FEEDBACK =
"Please use the Approve or Cancel buttons to respond to this approval.";
const APPROVAL_AUTHORIZER_TIMEOUT_MS = 10_000;
const APPROVAL_CANDIDATE_TTL_MS = 10 * 60_000;

Expand Down Expand Up @@ -142,21 +140,6 @@ export async function coordinateApprovalDelivery(input: {
);
const allRequests = batches.flatMap((batch) => batch.requests);
const requests = new Map(allRequests.map((request) => [request.requestId, request]));
if (
stepInput?.message !== undefined &&
(stepInput.attributedInputResponses?.length ?? 0) === 0 &&
(stepInput.inputResponses?.length ?? 0) === 0 &&
audit.activeCandidates.length === 0 &&
authorizationRequiredRequestIds.size > 0
) {
return deliveryResult(
session,
{ ...stepInput, message: undefined, messageAuth: undefined },
"park",
[],
[TEXT_APPROVAL_FEEDBACK],
);
}
const challenges: AuthorizationChallenge[] = [];
const feedback: string[] = [];
const consumed = new Set<string>();
Expand Down
Loading