mirror of
https://github.com/stablyai/orca.git
synced 2026-10-26 08:02:44 +00:00
fix: decode addressed Claude prompt text
This commit is contained in:
@@ -3,6 +3,7 @@ import { agentJournalItemKey } from '../../shared/agent-session-journal-item-key
|
||||
import { claudeQuestionItems } from './claude-structured-prompt-items'
|
||||
import {
|
||||
applyClaudePromptAnswer,
|
||||
encodeClaudeQuestionOptionId,
|
||||
type ClaudePendingPrompt
|
||||
} from './claude-structured-prompt-replies'
|
||||
|
||||
@@ -50,7 +51,9 @@ describe('Claude structured question addressing', () => {
|
||||
}
|
||||
const answer = 'https://example.test:8443/path'
|
||||
|
||||
expect(applyClaudePromptAnswer({ prompt }, answer)).toMatchObject({
|
||||
expect(
|
||||
applyClaudePromptAnswer({ prompt }, encodeClaudeQuestionOptionId('q1', answer))
|
||||
).toMatchObject({
|
||||
updatedInput: { answers: { [questionId]: answer } }
|
||||
})
|
||||
})
|
||||
@@ -71,7 +74,9 @@ describe('Claude structured question addressing', () => {
|
||||
}
|
||||
const answer = 'frontend, backend'
|
||||
|
||||
expect(applyClaudePromptAnswer({ prompt, questionId }, answer)).toMatchObject({
|
||||
expect(
|
||||
applyClaudePromptAnswer({ prompt, questionId }, encodeClaudeQuestionOptionId('q1', answer))
|
||||
).toMatchObject({
|
||||
updatedInput: { answers: { [questionId]: answer } }
|
||||
})
|
||||
})
|
||||
|
||||
@@ -57,10 +57,15 @@ function questionAnswer(prompt: ClaudePendingPrompt, questionId: string, optionI
|
||||
if (decoded.questionId === `q${questionIndex + 1}` && label) {
|
||||
return label
|
||||
}
|
||||
if (decoded.questionId === `q${questionIndex + 1}`) {
|
||||
return decoded.answer
|
||||
}
|
||||
const legacyChoice = options.some(
|
||||
(candidate) => isRecord(candidate) && readString(candidate.label) === decoded.answer
|
||||
)
|
||||
return decoded.questionId === questionId && legacyChoice ? decoded.answer : optionId
|
||||
return decoded.questionId === questionId && (legacyChoice || decoded.answer.trim().length > 0)
|
||||
? decoded.answer
|
||||
: optionId
|
||||
}
|
||||
|
||||
function questionId(question: Record<string, unknown>, index: number): string {
|
||||
|
||||
Reference in New Issue
Block a user