xonecas.io
7814
Ta

tiny-c-agent / files

tiny-c-agent / src / agent.h

1.3 KB
1// tiny agent: the loop that binds provider, session, and tool.
2
3#ifndef TINY_AGENT_H
4#define TINY_AGENT_H
5
6#include <stdbool.h>
7
8#include "event.h"
9#include "message.h"
10#include "provider.h"
11#include "session.h"
12
13typedef struct {
14    // Model and request shape.
15    tiny_model model;
16    const char *system_prompt;
17    const tiny_tool *tools;
18    size_t tools_len;
19
20    // Persistence. NULL disables session logging.
21    tiny_session *session;
22
23    // Projection. Both projections receive the same event stream.
24    tiny_event_fn on_event;
25    void *user;
26
27    // Interruption. All optional; NULL means the feature is absent.
28    bool (*is_pause_requested)(void *user);
29    void (*clear_pause)(void *user);
30    char *(*request_steering)(void *user);  // returns malloc'd text, or NULL
31    const volatile bool *cancel;
32
33    // Transcript, owned by the agent and kept across turns.
34    tiny_message *messages;
35    size_t messages_len;
36} tiny_agent;
37
38// Appends `input` as a user message, then loops until the model stops without
39// tool calls. Every outcome is reported as an event: complete, cancelled, or
40// error. The caller owns `model`, `runtime`, `session`, and the tools.
41void tiny_agent_turn(tiny_agent *a, const char *input);
42
43// Frees the transcript. Does not free the runtime, session, or model strings.
44void tiny_agent_free(tiny_agent *a);
45
46#endif