Rebuild Piggy's interface, and give the demo book a business to describe
Piggy answered in raw markdown, threw away every tool result it streamed, and fought the reader's scroll on every token. The three surfaces that made it worth having — what it read, how it reasoned, what it cost — were all on the wire and none of them reached the screen. The transcript is now composed of five parts under components/piggy: answers render through streamdown, the container sticks to the bottom without pinning the reader there, tool steps say what they read and link to the record, and each turn carries its model and token count. Three lifecycle bugs went with them: Stop left a permanent spinner, a truncated stream was indistinguishable from thinking, and a failed send destroyed the message it failed to send. Underneath, the inference path grew timeouts, jittered retries on 429 and 5xx, tolerance of the malformed frames a 30B model emits, and an agent_runs row per turn so chat spend is observable. The system prompt now states that a field ending in Cents is cents — without it nemotron renders costPerGpuHourCents: 189 as "$189 per GPU-hour", which is a 100x error on the most scrutinised number in the room. The demo book was arithmetically incoherent: every deal's value contradicted its own allocation revenue by up to 3.6x, nothing had ever closed, no customer had any paper, and the marketplace was empty. Deal value is now derived from the allocation, the book clears 5.3% across five blocks with one deliberately underwater, and the renewal, compliance and agent-provenance machinery finally has rows to act on. A --clear that deleted every obligation, SLA term and capacity request in the database regardless of origin is scoped to the demo's own ids. Around that: accounts have a detail page, ⌘K searches the book, Settings can mint the API keys it always claimed to, and deploy.sh actually ships the agent instead of silently skipping its compose profile. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,10 +16,29 @@ import { piggyChatRequestSchema } from '../src/chat-server';
|
||||
// answering over two sources where the page shows thirteen — all typecheck.
|
||||
const db = {} as Database;
|
||||
|
||||
/**
|
||||
* The lookup layer is on every message by design, so asserting it in each case
|
||||
* below would say nothing about selection. It is stripped here and covered on
|
||||
* its own in `lookup-tools.test.ts`; what these cases still pin is the FOCUSED
|
||||
* tool, which is the one that changes with where the user is standing.
|
||||
*/
|
||||
const LOOKUP_TOOLS = [
|
||||
'pig_search_records',
|
||||
'pig_get_record_by_id',
|
||||
'pig_list_renewals',
|
||||
'pig_list_inventory',
|
||||
];
|
||||
|
||||
function toolNames(context: Parameters<typeof createInteractivePigTools>[1]): string[] {
|
||||
const tools = createInteractivePigTools(db, context);
|
||||
assertPigToolBoundary(tools);
|
||||
return tools.map((tool) => tool.name);
|
||||
const names = tools.map((tool) => tool.name);
|
||||
assert.deepEqual(
|
||||
names.slice(-LOOKUP_TOOLS.length),
|
||||
LOOKUP_TOOLS,
|
||||
'the lookup layer is offered in every context, after the focused tool',
|
||||
);
|
||||
return names.slice(0, -LOOKUP_TOOLS.length);
|
||||
}
|
||||
|
||||
test('a page context selects the tool for that page and never pig_get_record', () => {
|
||||
@@ -62,6 +81,19 @@ test('no context reads the workspace, not six hundred rows of it', () => {
|
||||
assert.deepEqual(toolNames(undefined), ['pig_get_workspace_summary']);
|
||||
});
|
||||
|
||||
test('the calendar horizon accepts the null its emitted schema asks for', () => {
|
||||
const [calendar] = createInteractivePigTools(db, { type: 'page', route: '/calendar' });
|
||||
assert.ok(calendar);
|
||||
// `zodToJsonSchema(..., { target: 'openAi' })` emits an optional parameter as
|
||||
// required-and-nullable, so a model that follows the schema sends null and an
|
||||
// `.optional()` field would reject it — spending one of four turns on a tool
|
||||
// result that reads as a failure.
|
||||
assert.equal(calendar.inputSchema.safeParse({ withinDays: null }).success, true);
|
||||
assert.equal(calendar.inputSchema.safeParse({}).success, true);
|
||||
assert.equal(calendar.inputSchema.safeParse({ withinDays: 90 }).success, true);
|
||||
assert.equal(calendar.inputSchema.safeParse({ withinDays: 0 }).success, false);
|
||||
});
|
||||
|
||||
const validRequest = {
|
||||
principalUserId: '10000000-0000-4000-8000-000000000001',
|
||||
message: 'Where are we?',
|
||||
|
||||
Reference in New Issue
Block a user