Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(hetero): accept typed answers to remote Claude Code AskUserQuestion (#20021)

Arvin Xu3112b80ef0db
diff --git a/apps/server/src/services/heterogeneousAgent/HeterogeneousPersistenceHandler.ts b/apps/server/src/services/heterogeneousAgent/HeterogeneousPersistenceHandler.ts
index 988dd05fcae..29502d476ae 100644
--- a/apps/server/src/services/heterogeneousAgent/HeterogeneousPersistenceHandler.ts
+++ b/apps/server/src/services/heterogeneousAgent/HeterogeneousPersistenceHandler.ts
@@ -270,7 +270,16 @@ const buildHeterogeneousReviewDetail = (
};
}
case 'question': {
- return { questions, title: first.header, type: 'question' };
+ return {
+ // The shared AskUser form offers "write your own" on every question,
+ // plus whole-form freeform and a supplement note, and the producer's
+ // bridge formats all three. Declare them so the claim accepts typed
+ // answers instead of treating them as off-list selections.
+ answerPolicy: { allowFreeform: true, allowSupplement: true },
+ questions: questions.map((question) => ({ ...question, allowCustomAnswer: true })),
+ title: first.header,
+ type: 'question',
+ };
}
default: {
throw new Error('Unsupported heterogeneous intervention kind');
diff --git a/apps/server/src/services/heterogeneousAgent/__tests__/HeterogeneousPersistenceHandler.eventBranches.test.ts b/apps/server/src/services/heterogeneousAgent/__tests__/HeterogeneousPersistenceHandler.eventBranches.test.ts
index 524520884ed..e9f4dcb10e2 100644
--- a/apps/server/src/services/heterogeneousAgent/__tests__/HeterogeneousPersistenceHandler.eventBranches.test.ts
+++ b/apps/server/src/services/heterogeneousAgent/__tests__/HeterogeneousPersistenceHandler.eventBranches.test.ts
@@ -1104,6 +1104,50 @@ describe('HeterogeneousPersistenceHandler — event branch coverage', () => {
);
});
+ it('lets the user type their own answer to a heterogeneous question', async () => {
+ const h = createHarness({ topicAgentId: 'agent-test' });
+
+ await ingest(h, [
+ buildEvent('agent_intervention_request', 0, {
+ apiName: 'askUserQuestion',
+ arguments: JSON.stringify({
+ questions: [
+ {
+ header: 'Stack',
+ multiSelect: false,
+ options: [{ label: 'React' }, { label: 'Vue' }],
+ question: 'Which framework?',
+ },
+ {
+ header: 'Targets',
+ multiSelect: true,
+ options: [{ label: 'Web' }, { label: 'Desktop' }],
+ question: 'Which targets?',
+ },
+ ],
+ }),
+ deadline: 1_900_000_000_000,
+ identifier: 'claude-code',
+ interactionKind: 'question',
+ provider: 'claude-code',
+ toolCallId: 'claude-question-custom',
+ }),
+ ]);
+
+ // The shared AskUser form always offers "write your own", "type
+ // directly" and a supplement note; without these capabilities the claim
+ // rejects every typed answer as not matching the request.
+ const detail = notifyAgentInterventionRequired.mock.calls[0][0].items[0].detail;
+ expect(detail).toMatchObject({
+ answerPolicy: { allowFreeform: true, allowSupplement: true },
+ questions: [
+ { allowCustomAnswer: true, question: 'Which framework?' },
+ { allowCustomAnswer: true, question: 'Which targets?' },
+ ],
+ type: 'question',
+ });
+ });
+
it('uses only the sanitized first question for a multi-question summary', async () => {
const h = createHarness({ topicAgentId: 'agent-test' });