Skip to content

fix: reusable agent after stop#252

Open
linked-danis wants to merge 1 commit intoalibaba:mainfrom
linked-danis:pr1-reusable-agent
Open

fix: reusable agent after stop#252
linked-danis wants to merge 1 commit intoalibaba:mainfrom
linked-danis:pr1-reusable-agent

Conversation

@linked-danis
Copy link
Copy Markdown
Contributor

Reset AbortController and status when stop() is called. Agent can now be reused for subsequent tasks.

Changes:

  • Check if already stopped to prevent double-abort
  • Reset status to 'idle'
  • Create new AbortController for next task

What

Brief description of changes.

Type

  • Bug fix
  • Feature / Improvement
  • Refactor
  • Documentation
  • Website
  • Demo / Testing
  • Breaking change

Testing

  • Tested in modern browsers
  • No console errors
  • Types/doc added

Closes #(issue)

Requirements / 要求

  • I have read and follow the Code of Conduct and Contributing Guide . / 我已阅读并遵守行为准则。
  • This PR is NOT generated by a bot or AI agent acting autonomously. I have authored or meaningfully reviewed every change. / 此 PR 不是由 bot 或 AI 自主生成的,我已亲自编写或充分审查了每一处变更。

Reset AbortController and status when stop() is called.
Agent can now be reused for subsequent tasks.

Changes:
- Check if already stopped to prevent double-abort
- Reset status to 'idle'
- Create new AbortController for next task

/** Stop the current task. Agent remains reusable. */
stop() {
if (this.#abortController.signal.aborted) return // Already stopped
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn’t seem necessary.

this.pageController.hideMask()
this.#abortController.abort()
this.#setStatus('idle')
this.#abortController = new AbortController()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn’t seem necessary.

@gaomeng1900
Copy link
Copy Markdown
Collaborator

Maybe only keep this.#setStatus('idle') ?

Are you sure
if (this.#abortController.signal.aborted) return // Already stopped
and
this.#abortController = new AbortController()
actually make any difference?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants