mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-04-25 11:18:22 +00:00
refactor(config): thread AppConfig through RunContext into Worker
Phase 2 Task P2-5 (partial, Category D): RunContext gains an optional app_config field. Gateway deps.get_run_context populates it from app.state.config. Worker builds DeerFlowContext from ctx.app_config when provided, falling back to AppConfig.current() for legacy callers. This is the key path: Gateway-mode agent runs now construct DeerFlowContext without consulting the process-global at all — app_config flows from FastAPI's app.state through RunContext to Worker to Runtime.context. Standalone providers (checkpointer/store/stream_bridge) already accept optional config parameter from P1, so they are Phase 2-ready. 59 gateway/worker/run_manager tests pass.
This commit is contained in:
parent
23b424e7fc
commit
74b7a7eff9
@ -149,6 +149,7 @@ def get_run_context(request: Request) -> RunContext:
|
||||
event_store=get_run_event_store(request),
|
||||
run_events_config=getattr(config, "run_events", None),
|
||||
thread_store=get_thread_store(request),
|
||||
app_config=config,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -54,6 +54,9 @@ class RunContext:
|
||||
run_events_config: Any | None = field(default=None)
|
||||
thread_store: Any | None = field(default=None)
|
||||
follow_up_to_run_id: str | None = field(default=None)
|
||||
# Phase 2: app-level config flows through RunContext so Worker can build
|
||||
# DeerFlowContext without consulting the process-global.
|
||||
app_config: Any | None = field(default=None)
|
||||
|
||||
|
||||
async def run_agent(
|
||||
@ -169,7 +172,7 @@ async def run_agent(
|
||||
# LangGraph's astream(context=...) injects this into Runtime.context
|
||||
# so middleware/tools can access it via resolve_context().
|
||||
deer_flow_context = DeerFlowContext(
|
||||
app_config=AppConfig.current(),
|
||||
app_config=ctx.app_config if ctx.app_config is not None else AppConfig.current(),
|
||||
thread_id=thread_id,
|
||||
)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user