mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-06-10 17:35:57 +00:00
88e36d9686
* fix(#3189): prevent write_file streaming timeout on long reports Adds a layered defense against StreamChunkTimeoutError caused by oversized single-shot write_file tool calls: - factory: default stream_chunk_timeout to 240s for OpenAI-compatible clients (overridable via ModelConfig.stream_chunk_timeout in config.yaml) - sandbox/tools: server-side 80 KB length guard on non-append write_file calls (configurable via DEERFLOW_WRITE_FILE_MAX_BYTES env var, 0 disables); rejects oversized payloads with a structured error pointing the model at str_replace or append=True - middleware: classify StreamChunkTimeoutError as transient but cap retries at 1 via per-exception _RETRY_BUDGET_OVERRIDES (same-payload retry on a chunk-gap timeout buffers the same way upstream; full 3-attempt loop would stack 6-12 min of dead air) - middleware: surface an actionable user-facing message for stream-drop exceptions instead of leaking the raw langchain stack - prompts: add a routing-style File Editing Workflow hint to both lead_agent and general_purpose subagent prompts, pointing the model at str_replace for incremental edits (mirrors Claude Code's Edit / Codex's apply_patch) - tests: behavioural coverage for size guard, retry budget override, stream-drop user message, factory default injection Refs #3189 * fix(#3189): drop stream_chunk_timeout for non-OpenAI providers Address CR feedback on PR #3195: - factory: pop `stream_chunk_timeout` from kwargs for any model_use_path other than `langchain_openai:ChatOpenAI` instead of returning early. `ModelConfig.stream_chunk_timeout` is part of the shared schema, so a user-supplied value on a non-OpenAI provider would otherwise be forwarded to its constructor and raise `TypeError: unexpected keyword argument`. - factory: rewrite docstring to describe the actual `exclude_none=True` behaviour (explicit null is excluded and falls back to the default) instead of the misleading "None falling out via exclude_none=True keeps its value". - tests: add regression coverage asserting the kwarg is stripped before reaching a non-OpenAI provider's constructor. Refs: bytedance#3189 * fix(#3189): restrict stream-drop user copy to StreamChunkTimeoutError only Per CR on #3195: narrow _STREAM_DROP_EXCEPTIONS to StreamChunkTimeoutError. Generic httpx RemoteProtocolError / ReadError fall back to the standard 'temporarily unavailable' copy, since they routinely fire on transient network blips where the 'split the output' guidance is misleading. Retry/backoff classification is unchanged — both remain transient/retriable. Tests updated to reflect new copy, plus a symmetric regression test for ReadError. --------- Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
62 lines
2.7 KiB
Python
62 lines
2.7 KiB
Python
"""General-purpose subagent configuration."""
|
|
|
|
from deerflow.subagents.config import SubagentConfig
|
|
|
|
GENERAL_PURPOSE_CONFIG = SubagentConfig(
|
|
name="general-purpose",
|
|
description="""A capable agent for complex, multi-step tasks that require both exploration and action.
|
|
|
|
Use this subagent when:
|
|
- The task requires both exploration and modification
|
|
- Complex reasoning is needed to interpret results
|
|
- Multiple dependent steps must be executed
|
|
- The task would benefit from isolated context management
|
|
|
|
Do NOT use for simple, single-step operations.""",
|
|
system_prompt="""You are a general-purpose subagent working on a delegated task. Your job is to complete the task autonomously and return a clear, actionable result.
|
|
|
|
<guidelines>
|
|
- Focus on completing the delegated task efficiently
|
|
- Use available tools as needed to accomplish the goal
|
|
- Think step by step but act decisively
|
|
- If you encounter issues, explain them clearly in your response
|
|
- Return a concise summary of what you accomplished
|
|
- Do NOT ask for clarification - work with the information provided
|
|
</guidelines>
|
|
|
|
<file_editing_workflow>
|
|
When revising an existing file, prefer `str_replace` over `write_file` —
|
|
it sends only the diff and avoids re-emitting the whole file (mirrors
|
|
Claude Code's Edit and Codex's apply_patch). When writing long new
|
|
content from scratch, split it into sections: the first `write_file`
|
|
call creates the file, then use `write_file` with append=True to extend
|
|
it section by section. This keeps each tool call small and avoids
|
|
mid-stream chunk-gap timeouts on oversized single-shot writes.
|
|
(See issue #3189.)
|
|
</file_editing_workflow>
|
|
|
|
<output_format>
|
|
When you complete the task, provide:
|
|
1. A brief summary of what was accomplished
|
|
2. Key findings or results
|
|
3. Any relevant file paths, data, or artifacts created
|
|
4. Issues encountered (if any)
|
|
5. Citations: Use `[citation:Title](URL)` format for external sources
|
|
</output_format>
|
|
|
|
<working_directory>
|
|
You have access to the same sandbox environment as the parent agent:
|
|
- User uploads: `/mnt/user-data/uploads`
|
|
- User workspace: `/mnt/user-data/workspace`
|
|
- Output files: `/mnt/user-data/outputs`
|
|
- Deployment-configured custom mounts may also be available at other absolute container paths; use them directly when the task references those mounted directories
|
|
- Treat `/mnt/user-data/workspace` as the default working directory for coding and file IO
|
|
- Prefer relative paths from the workspace, such as `hello.txt`, `../uploads/input.csv`, and `../outputs/result.md`, when writing scripts or shell commands
|
|
</working_directory>
|
|
""",
|
|
tools=None, # Inherit all tools from parent
|
|
disallowed_tools=["task", "ask_clarification", "present_files"], # Prevent nesting and clarification
|
|
model="inherit",
|
|
max_turns=100,
|
|
)
|