Files
lotherk 4cbd57d829 tree: lcm keeps the task, and the in-flight work it sits in
Everything that was uncommitted in the shared tree, in one commit because the
changes are interleaved across the same files (lcm, engine, frontend, locales).

lcm: a continuation prompt is not the task. After /resume the newest user
message is "Continue with the task ...", and pinning it kept the keystroke
while the question it continues was cut away -- measured: a resumed session
woke up with the prompt, one tool call and its error, and no task at all. The
pin now skips the harness's own continuation prompts, so the real question is
pinned again. test_compactor drives it: with the skip disabled the task is
lost (red), with it the task comes back after the summary (green).

engine: /self-check and the exact tool-argument parse are in a1794fb; this
commit carries the tests for them (a failed tool observation must appear in
the self-check prompt; mcp_parse_exact rejects two objects in one string) and
the i18n keys the new code uses: cmd.script.*, main.no_profile, tg.busy,
tg.interview.running, ui.agent_busy in all three catalogues.

The rest is the in-flight work from the shared session: engine/frontend,
plugins, telegram/a2a, and their tests.

make check: all tests passed; check_i18n ok, 204 keys in 3 catalogues.
2026-11-18 23:03:09 +00:00

80 lines
1.8 KiB
C

/* splinter -- conversation tests. */
#include <stdio.h>
#include <string.h>
#include "splinter.h"
static int failures;
#define CHECK(cond) do { \
if (!(cond)) { \
fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #cond); \
failures++; \
} \
} while (0)
int
main(void)
{
struct sp_conv c;
struct sp_msg m;
sp_conv_init(&c);
CHECK(c.n == 0);
CHECK(sp_conv_bytes(&c) == 0);
CHECK(sp_conv_push(&c, "user", NULL, "hallo") == 0);
CHECK(sp_conv_push(&c, "assistant", NULL, "hi") == 0);
CHECK(c.n == 2);
CHECK(strcmp(c.v[0].role, "user") == 0);
CHECK(strcmp(c.v[0].content, "hallo") == 0);
CHECK(c.v[0].name == NULL);
CHECK(c.v[0].call_id == NULL);
/* a tool message carries name and call id */
memset(&m, 0, sizeof(m));
m.role = "tool";
m.name = "echo";
m.call_id = "call-7";
m.content = "pong";
CHECK(sp_conv_add(&c, &m) == 0);
CHECK(c.n == 3);
CHECK(strcmp(c.v[2].name, "echo") == 0);
CHECK(strcmp(c.v[2].call_id, "call-7") == 0);
/* an assistant turn that asked for tools keeps the provider's raw array */
memset(&m, 0, sizeof(m));
m.role = "assistant";
m.content = "";
m.calls = "[{\"id\":\"call-7\",\"type\":\"function\",\"function\":"
"{\"name\":\"echo\",\"arguments\":\"x\"}}]";
CHECK(sp_conv_add(&c, &m) == 0);
CHECK(c.v[3].calls != NULL);
/* the copy is a copy: changing the source must not change the record */
{
char buf[16];
snprintf(buf, sizeof(buf), "hallo");
buf[0] = 'H';
CHECK(strcmp(c.v[0].content, "hallo") == 0);
}
/* a message without a role is refused */
memset(&m, 0, sizeof(m));
m.content = "x";
CHECK(sp_conv_add(&c, &m) == -1);
CHECK(c.n == 4);
/* bytes grow with the content */
CHECK(sp_conv_bytes(&c) > 0);
sp_conv_free(&c);
CHECK(c.n == 0);
CHECK(c.v == NULL);
if (failures == 0)
printf("test_conv: ok\n");
return failures == 0 ? 0 : 1;
}