协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
agents-and-awel【开发与工程】Build and debug DB-GPT agents, tools, skills, teams, and AWEL workflows, including deterministic local DAG runs and HTTP-trigger topology without assuming an LLM, credential, or external service.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this route when the task mentions dbgpt.agent, ConversableAgent, profiles,
agent context or memory, tools, skills, middleware, teams, prompts, AWEL/DAG/flow,
MapOperator, HTTP triggers, flow variables, or local workflow execution. Keep the
work local and deterministic unless the user explicitly supplies a model, service, and
credentials. Route these elsewhere:
data-and-rag;models-and-serving;apis-client-and-sandbox.ConversableAgent needs a
ProfileConfig (unless a subclass supplies one). Bind the AgentContext before
build(). Bind the LLM configuration and required memory/resources/actions before
build() as described in agent-api-reference.md.
bind() is synchronous and returns the same agent; build() is async.ToolPack, and bind the pack before an action that consumes it is
built. A Skill sets the agent's prompt when bound, but its declared
required_tools and required_knowledge are not a substitute for binding and
checking actual resources.DAG("stable-id"), instantiate
operators inside with dag:, use explicit task_id/task_name where serialized
identity matters, and connect nodes with >>. Inspect root_nodes, leaf_nodes,
and trigger_nodes before running. Follow the stream and join constraints in
awel-workflows.md.scripts/awel_smoke.py for an independent no-model/no-
network topology and execution check. Only then mount into the application's
supported router or start a development server.leaf.call()/call_stream() use a local runner in the
current process. An HttpTrigger mounted on an app invokes the leaf through the
HTTP request path. A production DB-GPT service must register/load the DAG and
provide the application lifecycle; setup_dev_environment() is a development
helper and can start a blocking Uvicorn process.from dbgpt.core.awel import DAG, InputOperator, MapOperator, SimpleInputSource
with DAG("double-local") as dag:
source = InputOperator(SimpleInputSource(21), task_name="source")
doubled = MapOperator(lambda value: value * 2, task_name="doubled")
source >> doubled
result = await doubled.call()
# result == 42
For a callable that is not known to be serializable, use it only for local experimentation. Serialized/deployed flows should use registered operator classes, metadata, stable IDs, and serializable callables; see awel-workflows.md.
from dbgpt._private.pydantic import BaseModel, Field
from dbgpt.core.awel import DAG, HttpTrigger, MapOperator
class RequestBody(BaseModel):
name: str = Field(..., description="User name")
age: int = Field(18, description="User age")
class Greeting(MapOperator[RequestBody, str]):
async def map(self, body: RequestBody) -> str:
return f"Hello, {body.name}; age={body.age}"
with DAG("greeting-flow") as dag:
trigger = HttpTrigger(
"/examples/greeting/{dag_id}", methods="POST", request_body=RequestBody
)
leaf = Greeting(task_name="greeting")
trigger >> leaf
The trigger normalizes a missing leading slash, resolves {dag_id} from its DAG, and
requires exactly one leaf when it runs through HTTP. POST/PUT-style routes receive a
pydantic body; GET/DELETE model fields become query parameters. Mounting on a plain
FastAPI APIRouter is suitable for inspection via mount_to_router; DB-GPT's app
mount path uses its supported priority router. Do not infer a live server from router
registration alone.
The core skill API is exported from dbgpt.agent.skill: Skill, SkillMetadata,
SkillType, SkillBuilder, SkillLoader, SkillManager, initialize_skill, and
get_skill_manager. A file-based SKILL.md must begin with YAML frontmatter and have
name and description; its instructions are the remainder of the file. A
SkillsMiddleware exposes metadata first and reads full content on demand. Later
configured directories override earlier names. Skill matching is simple keyword
matching, not semantic routing, so always verify the selected skill explicitly.
Details and safe fixture rules are in skills-and-tools.md.
AgentContext carries conv_id, language, round/retry limits, generation settings,
and opt-in context management. ContextBudgetConfig.effective_budget is
max_context_tokens - reserved_tokens; the default maximum is 120000 and the
default reserved output space is 4096.ConversableAgent.check_available() requires context, action resources where an
action declares resource_need, and an LLM config/client for non-human,
non-team agents. build() preloads resources, performs this check, initializes
actions and memory, and wraps the configured LLM client.AgentMessage is the communication object. Preserve content, role, context,
action_report, review_info, current_goal, and success state when forwarding
or serializing messages. Use to_llm_message() only when the reduced LLM shape is
intended.@tool creates a FunctionTool wrapper with ._tool; synchronous and async
functions must be executed through their matching execute/async_execute path.
Missing docstrings/descriptions and malformed explicit args are validation errors.MiddlewareManager executes registered middleware in registration order and skips
disabled middleware. Hook return dictionaries are merged; system-prompt hooks are
applied sequentially. Middleware state is not automatically agent state.DAG IDs are caller-supplied strings; node IDs default to UUIDs. Node names must be
unique inside a DAG. MapOperator expects one parent during normal graph execution,
JoinOperator accepts multiple parents, and ReduceStreamOperator requires stream
input. call_stream() wraps a non-stream output as a one-item async stream.HttpTrigger itself does not support direct trigger() execution. It delegates to
the DAG's single leaf; streaming uses call_stream() and normally returns
text/event-stream unless response settings override it.MCPToolPack, code/shell tools, personal skill
scripts, and provider-backed agent examples as optional side-effectful integrations.scripts/awel_smoke.py — safe local topology, router metadata, pydantic validation,
and tiny-fixture DAG execution; it never starts a server or calls a model.