routes.history
FastAPI routes for conversation history.
HistoryMessage Objects
class HistoryMessage(BaseModel)
Message in the conversation history.
role
"user", "assistant", "system", "tool"
createdAt
ISO timestamp
HistoryResponse Objects
class HistoryResponse(BaseModel)
Response containing conversation history.
HistoryUpsertRequest Objects
class HistoryUpsertRequest(BaseModel)
Request payload for injecting/restoring conversation history.
InputMessage Objects
class InputMessage(BaseModel)
Validated chat message payload accepted by upsert endpoint.
get_conversation_history
@router.get("/history", response_model=HistoryResponse)
async def get_conversation_history(agent_id: str = Query(
default="default",
description="Agent ID to get history for")) -> HistoryResponse
Get the conversation history for an agent.
Returns messages in the format expected by the frontend ChatMessage interface.
upsert_conversation_history
@router.post("/history", response_model=dict)
async def upsert_conversation_history(
body: HistoryUpsertRequest,
agent_id: str = Query(default="default",
description="Agent ID to restore history for")
) -> dict[str, Any]
Inject/restore conversation history for an agent.
clear_conversation_history
@router.delete("/history", response_model=dict)
async def clear_conversation_history(agent_id: str = Query(
default="default",
description="Agent ID to clear history for")) -> dict[str, Any]
Clear the conversation history for an agent.
This resets the message history but preserves usage statistics.