Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AISecurityLab Hackagent Chat Messages

From Leeroopedia
Knowledge Sources
Domains Contracts
Last Updated 2026-10-29 00:00 GMT

Overview

Concrete frozen pydantic models for chat messages and tool calls, defining the wire format for all LLM communication in HackAgent, provided by the core contracts package.

Description

ToolCall represents a tool invocation requested by a model (id, name, arguments as string). Message is one chat message with role (system/user/assistant/tool), content (text or OpenAI-style content parts), tool_calls, and tool_call_id. Both are frozen pydantic models.

Usage

  • Model calls: LLM.complete() accepts a sequence of Message or dicts.
  • Tool results: Tool result messages use role "tool" with tool_call_id.

Code Reference

Source Location

Signature

class ToolCall(BaseModel):
    id: Optional[str] = None
    name: str
    arguments: str = ""

class Message(BaseModel):
    role: Literal["system", "user", "assistant", "tool"]
    content: Union[str, List[Dict[str, Any]], None] = None
    tool_calls: List[ToolCall] = []
    tool_call_id: Optional[str] = None

Import

from hackagent.core.contracts import Message, ToolCall

Usage Examples

Build a Message List

from hackagent.core.contracts import Message

messages = [
    Message(role="system", content="You are helpful."),
    Message(role="user", content="Hello!"),
]
result = model.complete(messages)

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment