Files
wehub-resource-sync 1443d3fdf9
Ruff Format Check / Ruff Format & Lint (push) Failing after 7m39s
Deploy VitePress site to Pages / build (push) Failing after 9m11s
Deploy VitePress site to Pages / Deploy (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:32:26 +08:00

33 lines
833 B
Python

"""Define the state structures for the agent."""
from __future__ import annotations
from typing import Annotated, TypedDict
from langchain.agents import AgentState
def merge_artifacts(existing: list[str] | None, new: list[str] | None) -> list[str]:
"""Merge artifact file paths while preserving order and removing duplicates."""
if existing is None:
return new or []
if new is None:
return existing
return list(dict.fromkeys(existing + new))
class BaseState(AgentState):
"""Shared state fields for Yuxi agents."""
artifacts: Annotated[list[str], merge_artifacts]
class AgentStatePayload(TypedDict):
"""Serialized agent state payload consumed by the frontend."""
todos: list
files: dict
artifacts: list[str]
subagent_runs: list[dict]
token_usage: dict | None