Tool log: persist agent tool calls in messages
Some checks failed
Deploy Tracker / deploy (push) Failing after 3s
Some checks failed
Deploy Tracker / deploy (push) Failing after 3s
- Message model: tool_log JSON column (array of {name, args, result, error})
- chat.send WS handler accepts tool_log
- MessageOut schema includes tool_log
- Converters pass tool_log through
This commit is contained in:
parent
f07bbfe6fc
commit
ff6b32316c
@ -84,6 +84,7 @@ def message_out(m: Message) -> MessageOut:
|
|||||||
author=member_brief(m.author) if m.author else None,
|
author=member_brief(m.author) if m.author else None,
|
||||||
content=m.content,
|
content=m.content,
|
||||||
thinking=m.thinking,
|
thinking=m.thinking,
|
||||||
|
tool_log=m.tool_log,
|
||||||
mentions=_resolve_mentions(m),
|
mentions=_resolve_mentions(m),
|
||||||
actor=member_brief(m.actor) if hasattr(m, 'actor') and m.actor else None,
|
actor=member_brief(m.actor) if hasattr(m, 'actor') and m.actor else None,
|
||||||
voice_url=m.voice_url,
|
voice_url=m.voice_url,
|
||||||
|
|||||||
@ -61,6 +61,7 @@ class MessageOut(BaseModel):
|
|||||||
author: MemberBrief | None = None
|
author: MemberBrief | None = None
|
||||||
content: str
|
content: str
|
||||||
thinking: str | None = None
|
thinking: str | None = None
|
||||||
|
tool_log: list[dict] | None = None
|
||||||
mentions: list[MemberBrief] = []
|
mentions: list[MemberBrief] = []
|
||||||
actor: MemberBrief | None = None
|
actor: MemberBrief | None = None
|
||||||
voice_url: str | None = None
|
voice_url: str | None = None
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
import uuid
|
import uuid
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from sqlalchemy import ForeignKey, Integer, String, Text
|
from sqlalchemy import ForeignKey, Integer, JSON, String, Text
|
||||||
from sqlalchemy.dialects.postgresql import ARRAY, UUID
|
from sqlalchemy.dialects.postgresql import ARRAY, UUID
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
@ -47,6 +47,9 @@ class Message(Base):
|
|||||||
# Actor — who initiated the action (for system messages: who created/moved/assigned the task)
|
# Actor — who initiated the action (for system messages: who created/moved/assigned the task)
|
||||||
actor_id: Mapped[uuid.UUID | None] = mapped_column(ForeignKey("members.id"), nullable=True)
|
actor_id: Mapped[uuid.UUID | None] = mapped_column(ForeignKey("members.id"), nullable=True)
|
||||||
|
|
||||||
|
# Tool log — JSON array of tool calls [{name, args, result, error?}]
|
||||||
|
tool_log: Mapped[dict | None] = mapped_column(JSON, nullable=True)
|
||||||
|
|
||||||
# Content
|
# Content
|
||||||
content: Mapped[str] = mapped_column(Text, nullable=False)
|
content: Mapped[str] = mapped_column(Text, nullable=False)
|
||||||
thinking: Mapped[str | None] = mapped_column(Text, nullable=True) # LLM reasoning/thinking block
|
thinking: Mapped[str | None] = mapped_column(Text, nullable=True) # LLM reasoning/thinking block
|
||||||
|
|||||||
@ -42,6 +42,7 @@ def _to_message_out(msg: Message, author: Member | None = None) -> MessageOut:
|
|||||||
author=_to_member_brief(author) if author else None,
|
author=_to_member_brief(author) if author else None,
|
||||||
content=msg.content,
|
content=msg.content,
|
||||||
thinking=msg.thinking,
|
thinking=msg.thinking,
|
||||||
|
tool_log=msg.tool_log,
|
||||||
mentions=mention_briefs,
|
mentions=mention_briefs,
|
||||||
actor=_to_member_brief(msg.actor) if hasattr(msg, 'actor') and msg.actor else None,
|
actor=_to_member_brief(msg.actor) if hasattr(msg, 'actor') and msg.actor else None,
|
||||||
voice_url=msg.voice_url,
|
voice_url=msg.voice_url,
|
||||||
@ -287,6 +288,7 @@ async def _handle_chat_send(session_id: str, data: dict):
|
|||||||
task_id = data.get("task_id")
|
task_id = data.get("task_id")
|
||||||
content = data.get("content", "")
|
content = data.get("content", "")
|
||||||
thinking = data.get("thinking")
|
thinking = data.get("thinking")
|
||||||
|
tool_log = data.get("tool_log")
|
||||||
mentions = data.get("mentions", [])
|
mentions = data.get("mentions", [])
|
||||||
|
|
||||||
if not content:
|
if not content:
|
||||||
@ -306,6 +308,7 @@ async def _handle_chat_send(session_id: str, data: dict):
|
|||||||
author_id=member.id,
|
author_id=member.id,
|
||||||
content=content,
|
content=content,
|
||||||
thinking=thinking,
|
thinking=thinking,
|
||||||
|
tool_log=tool_log,
|
||||||
mentions=mentions,
|
mentions=mentions,
|
||||||
)
|
)
|
||||||
db.add(msg)
|
db.add(msg)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user