router: agenda questions belong to query, not to system
"что у меня сегодня" and "что у меня в календаре сегодня" both routed IntentSystem on the deployed daemon, and replySystem has no agenda arm, so both answered "пока не умею". The calendar source that can answer them lives in the query chain and was never reached. The fixture has said query since ru-query-019 was written; the daemon disagreed with the fixture and the daemon was wrong. AgendaQueryGrammars routes them at stage 0, after the clock rules so "какой сегодня день" keeps reaching replySystem. Intent only — which source claims the turn stays the query chain's decision. This is what made the follow-up continuation look like it only worked for "what day is it". It did: the query half inherited an intent whose handler could not answer, so both halves came back "пока не умею". Measured on the 77-case RU fixture: full accuracy 70.1% → 72.7%, intent-only 75.3% → 77.9%, calendar 0/2 → 2/2, clarify counts unchanged. The eval harness wires the new grammars too, or the fixture would stop being a measurement of the daemon. Go's \b is ASCII-only and never fires after a Cyrillic letter, which the first version of the pattern learned the hard way. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TrVSBKe3RFDF4fGYKWYQnX
This commit is contained in:
@@ -140,6 +140,62 @@ func SystemTimeDateGrammars() []Grammar {
|
||||
}
|
||||
}
|
||||
|
||||
// AgendaQueryGrammars — stage-0 grammars for "what have I got on" questions,
|
||||
// routed to IntentQuery so they reach the query chain (queryDayPlan,
|
||||
// queryCalendar) instead of replySystem.
|
||||
//
|
||||
// This exists because the model puts them in IntentSystem. Measured on the
|
||||
// deployed daemon 01-08-2026: "что у меня сегодня" and "что у меня в календаре
|
||||
// сегодня" both routed system, and replySystem has no agenda arm, so both
|
||||
// answered "пока не умею". The fixture has said query since ru-query-019 was
|
||||
// written ("the clock/date system rule must not swallow it"); the daemon
|
||||
// disagreed with the fixture and the daemon was wrong.
|
||||
//
|
||||
// Routing, not answering. These set the intent and nothing else — which source
|
||||
// in the query chain claims the turn stays the chain's decision, and a
|
||||
// question with no date still falls through queryCalendar to recall.
|
||||
//
|
||||
// Deliberately not folded into SystemTimeDateGrammars: those exist to send
|
||||
// utterances TO system, these exist to keep utterances OUT of it, and one
|
||||
// function returning both would read as a list of clock rules.
|
||||
func AgendaQueryGrammars() []Grammar {
|
||||
return []Grammar{
|
||||
{
|
||||
// An explicit calendar noun is unambiguous wherever it appears:
|
||||
// "что в календаре на завтра", "покажи расписание на среду".
|
||||
Name: "calendar-query",
|
||||
Pattern: regexp.MustCompile(`(?i)(календар|расписани|повестк)`),
|
||||
Build: agendaQueryBuild,
|
||||
},
|
||||
{
|
||||
// The agenda phrasing with no calendar noun. Anchored at the start
|
||||
// and requiring the possessive, so it reads as a question about his
|
||||
// day: "что у меня сегодня", "что у меня стоит на послезавтра".
|
||||
// "у меня кончилась вода" is a fact and does not match.
|
||||
Name: "agenda-query",
|
||||
// (\s|[?!.]|$) rather than \b: Go's \b is ASCII-only, so it does
|
||||
// not see a boundary after a Cyrillic letter and the pattern
|
||||
// silently never fires.
|
||||
// "во сколько у меня встреча" is the same agenda question with a
|
||||
// clock word in front, and the clock word is what sent it to
|
||||
// system (fixture ru-query-013).
|
||||
Pattern: regexp.MustCompile(`(?i)^\s*(что|чего|какие|сколько|во\s+сколько|когда)\s+у\s+меня(\s|[?!.]|$)`),
|
||||
Build: agendaQueryBuild,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// agendaQueryBuild — shared Build for the agenda grammars. Confidence 1.0 on
|
||||
// the intent only: the utterance travels intact and the query chain's own
|
||||
// matchers decide the rest.
|
||||
func agendaQueryBuild(m []string) (Decision, bool) {
|
||||
return Decision{
|
||||
Stage: 0,
|
||||
Intent: IntentQuery,
|
||||
Confidence: 1.0,
|
||||
}, true
|
||||
}
|
||||
|
||||
// timeQueryBuild — Build for the time-query grammar. Returns ok=false for
|
||||
// elapsed/duration queries ("сколько времени прошло", "сколько времени
|
||||
// осталось", "сколько времени до") so they fall through to the classifier.
|
||||
|
||||
Reference in New Issue
Block a user