Skip to content

fix: keep new agent bootstrap in user scope#2784

Open
Eilen6316 wants to merge 1 commit intobytedance:mainfrom
Eilen6316:fix-agent-bootstrap-user-dir
Open

fix: keep new agent bootstrap in user scope#2784
Eilen6316 wants to merge 1 commit intobytedance:mainfrom
Eilen6316:fix-agent-bootstrap-user-dir

Conversation

@Eilen6316
Copy link
Copy Markdown
Contributor

Summary

  • avoid pre-creating an empty custom agent before the bootstrap flow saves it
  • pass agent_name with the initial bootstrap message so setup_agent writes the named agent
  • stamp the authenticated user_id into run context and have setup_agent prefer it for user-scoped persistence

Closes #2782

Tests

  • uv run pytest tests/test_setup_agent_tool.py tests/test_gateway_services.py -q
  • uv run ruff check app/gateway/services.py packages/harness/deerflow/tools/builtins/setup_agent_tool.py tests/test_gateway_services.py tests/test_setup_agent_tool.py
  • pnpm exec tsc --noEmit

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the “New Agent” bootstrap flow so that a named custom agent is only persisted after the bootstrap/save sequence completes, and it is always persisted under the authenticated user’s scope (not the default user bucket).

Changes:

  • Frontend no longer pre-creates an empty custom agent; instead it passes agent_name in the initial bootstrap message context.
  • Gateway stamps the authenticated user_id into the run context so background tool execution can reliably persist user-scoped files.
  • setup_agent now prefers runtime.context["user_id"] (when present) to avoid falling back to default when ContextVars aren’t available.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
frontend/src/core/i18n/locales/zh-CN.ts Updates bootstrap copy to instruct designing SOUL.md before saving.
frontend/src/core/i18n/locales/en-US.ts Updates bootstrap copy to reflect the revised save-first flow.
frontend/src/app/workspace/agents/new/page.tsx Removes empty-agent pre-creation and forwards agent_name via message context.
backend/tests/test_setup_agent_tool.py Adds regression coverage ensuring runtime user_id is used when ContextVar user is missing.
backend/tests/test_gateway_services.py Adds test ensuring authenticated user_id overrides any client-supplied user_id in run context.
backend/packages/harness/deerflow/tools/builtins/setup_agent_tool.py Uses runtime context user_id for user-scoped agent persistence.
backend/app/gateway/services.py Injects authenticated user_id into run context before background execution.

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.

[Bug] 在New Agent时输入名字之后没有等用户prompt具体内容就直接think完后完成Agent 创建

2 participants