feat: support function factory (#4)

This commit is contained in:
DanielWalnut
2026-01-15 22:05:54 +08:00
committed by GitHub
parent a39f799a7e
commit b44144dd2c
9 changed files with 133 additions and 22 deletions

View File

@@ -71,8 +71,9 @@ class ThreadDataMiddleware(AgentMiddleware[ThreadDataMiddlewareState]):
@override
def before_agent(self, state: ThreadDataMiddlewareState, runtime: Runtime) -> dict | None:
# Generate new thread ID and create directories
print(runtime.context)
thread_id = runtime.context["thread_id"]
thread_id = runtime.context.get("thread_id")
if thread_id is None:
raise ValueError("Thread ID is required in the context")
paths = self._create_thread_directories(thread_id)
print(f"Created thread data directories for thread {thread_id}")