Log
The log library lets an agent run sql queries on its own event log.
Methods
| Method | Inputs | Description |
|---|---|---|
describe | type?, cursor?, limit? | Discover columns, event types, schemas, and observed fields. |
search | query, type?, from?, through?, limit? | Find events using full-text search. |
query | sql, from?, through? | Query event history using read-only SQL. |
Agent usage
Select the log library in the agent's tools:
agent.ts
import { Effect } from "effect"
import { Agent } from "tardie/agent"
import { Actor } from "tardie/core"
import { log } from "tardie/libraries"
const program = Effect.gen(function* () {
const tools = yield* Agent.tools([log])
const context = yield* Agent.compact(Agent.messages)
return yield* Agent.make({
system: "Use the log tools to find relevant information in your event history.",
tools,
context,
})
})
export const assistant = Actor.make("assistant", program)
Host wiring
Supply the journal implementation through the host layer. The host provides the current thread's EventLog:
worker.ts
import { Layer } from "effect"
import { host, journal } from "tardie/platform/cloudflare"
import { assistant } from "./agent"
import { model } from "./model"
const worker = host(assistant, {
layer: Layer.mergeAll(model, journal()),
})
export const ActorDO = worker.ActorObject
export const ThreadDO = worker.ThreadObject
export default worker