feat(agent): mv <agent_state> in front of <agent_history>

This commit is contained in:
Simon
2026-01-10 17:44:08 +08:00
parent 5237edfcca
commit 4e52f17b9f

View File

@@ -364,23 +364,6 @@ export class PageAgent extends EventTarget {
async #assembleUserPrompt(): Promise<string> {
let prompt = ''
// <agent_history>
// - <step_>
prompt += '<agent_history>\n'
this.history.forEach((history, index) => {
prompt += `<step_${index + 1}>
Evaluation of Previous Step: ${history.brain.evaluation_previous_goal}
Memory: ${history.brain.memory}
Next Goal: ${history.brain.next_goal}
Action Results: ${history.action.output}
</step_${index + 1}>
`
})
prompt += '</agent_history>\n\n'
// <agent_state>
// - <user_request>
// - <step_info>
@@ -397,6 +380,23 @@ export class PageAgent extends EventTarget {
</agent_state>
`
// <agent_history>
// - <step_>
prompt += '\n<agent_history>\n'
this.history.forEach((history, index) => {
prompt += `<step_${index + 1}>
Evaluation of Previous Step: ${history.brain.evaluation_previous_goal}
Memory: ${history.brain.memory}
Next Goal: ${history.brain.next_goal}
Action Results: ${history.action.output}
</step_${index + 1}>
`
})
prompt += '</agent_history>\n\n'
// <browser_state>
prompt += await this.#getBrowserState()