Skip to content

enhance: simplify the question agent flow#1541

Draft
a7m-1st wants to merge 6 commits intomainfrom
enhance/quick_reply_a7m
Draft

enhance: simplify the question agent flow#1541
a7m-1st wants to merge 6 commits intomainfrom
enhance/quick_reply_a7m

Conversation

@a7m-1st
Copy link
Copy Markdown
Collaborator

@a7m-1st a7m-1st commented Apr 6, 2026

Related Issue

Closes ##1540

Description

Issue 1

  • Previously when a question gets sent, it was passing through two stages:
  1. Question Agent decides if task is complex / no
is_complex_task = await question_confirm(
    question_agent, question, task_lock
)
  1. Question Agent replies if task is simple
simple_resp = question_agent.step(simple_answer_prompt)
if simple_resp and simple_resp.msgs:
    answer_content = simple_resp.msgs[0].content
  • The issue with this is speed ofcourse; so instead of making them separate prompts why can't the agent just return this?:
Respond in this exact format:
COMPLEXITY: [SIMPLE|COMPLEX]
ANSWER: [Direct answer only if SIMPLE. Leave blank if COMPLEX]"""

Issue 2

  • Also, the question agent had almost no context of the environment. Thus in this PR I gave context to mcp and files attached additionally.
image
  • I have left some TODO's regarding the old implementation. To be covered in upcoming PRs. They include the fact that options is frozen on multi turn, and attached files, mcps and other artifacts remains frozen among turns too. Human reply tool is also affected where no file information is passed along multi turn.

Testing Evidence (REQUIRED)

It doesn't break the SSE.

  • Fun fact before you comment; TTFT actually is within 1 - 2 sec in the backend; I guess initialization stretched it longer. We can see that times were 16s, 9s, 8s. It is not very stable, but has overall improvement.
2026-04-06.05-47-04.mp4
  • I have included human-verified testing evidence in this PR.
  • This PR includes frontend/UI changes, and I attached screenshot(s) or screen recording(s).
  • No frontend/UI changes in this PR.

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Contribution Guidelines Acknowledgement

@a7m-1st a7m-1st self-assigned this Apr 6, 2026
@a7m-1st a7m-1st added enhancement New feature or request backend labels Apr 6, 2026
@a7m-1st a7m-1st marked this pull request as draft April 6, 2026 03:16
@a7m-1st
Copy link
Copy Markdown
Collaborator Author

a7m-1st commented Apr 8, 2026

Update 080426:

image
  1. Parallel calls; inside startTask. Also made history creation async (non awaited).
  2. Caching: Fetching user keys was taking 2 seconds, so I have cached it for 5 minutes with TanStack query and invalidated when chat ends SSE and invalidate with default events by default (chatBox/index.tsx load, refocus & model change)

@a7m-1st
Copy link
Copy Markdown
Collaborator Author

a7m-1st commented Apr 8, 2026

Update

  • Model backend hashing implemented for cross project reuse. Lowers the question agent time to:
  • 5 seconds for "hi" (from ~14 seconds)
  • 2:41 min for "write for me hello word text file then save it." (from ~3:30 min)

@a7m-1st a7m-1st marked this pull request as ready for review April 8, 2026 19:22
Comment on lines 1201 to +1202
)
is_multi_turn_complex = await question_confirm(
question_agent, new_task_content, task_lock
)
is_multi_turn_complex = True
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This added to bypass error. This event is not used anymore; patching it in #1438 .

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

Labels

backend enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants