mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-04 15:28:40 +00:00
serve: the picture guard inside the replaced-reply rule; its log line marked [DRAFT]
live_tail_is_replaced_reply() takes the live branch's picture positions and answers "park as before" when one is at or past the resume point (unit case picture_at_or_past_checkpoint_parks in reply_branch_test, 16 cases); generate.cpp passes live_imgs' starts instead of checking them beside the call. Same behaviour: a chat request's reply holds no picture, so the guard does not fire from the chat API. The engine log line of P3 now starts with "[DRAFT] " until the owner words it (par\OWNER-WORDING-1111.md). Lane AGENT-TURN, P3 follow-up.
This commit is contained in:
1 parent
be101072ba
commit
77c344bdd0
3 files changed
+16
-5
No files matched your search
@@ -23,11 +23,14 @@ namespace strata::program {
|
||||
// ids[resume + 1] == live[resume + 1]): the same assistant turn, re-sent or opened again;
|
||||
// - live and the prompt agree on [0, resume) (the caller resumes from a checkpoint of exactly those tokens; checked
|
||||
// here again so the rule stands alone).
|
||||
// Pictures are the caller's: it asks only when the live branch has none at or past `resume`.
|
||||
// - the live branch has no picture at or past `resume` (`live_pictures`: where each of its pictures starts): a branch
|
||||
// whose tail holds a picture is parked as before (a chat request's reply holds none, so this is a guard).
|
||||
template<class LiveTok, class PromptTok>
|
||||
bool live_tail_is_replaced_reply(const std::vector<LiveTok>& live, const std::vector<PromptTok>& ids, int64_t resume,
|
||||
int64_t turn_token) {
|
||||
int64_t turn_token, const std::vector<int64_t>& live_pictures = {}) {
|
||||
if (turn_token < 0 || resume < 1) return false;
|
||||
for (const int64_t at : live_pictures)
|
||||
if (at >= resume) return false;
|
||||
const auto r = static_cast<std::size_t>(resume);
|
||||
if (live.size() < r + 2 || ids.size() < r + 2) return false;
|
||||
if (static_cast<int64_t>(live[r]) != turn_token || static_cast<int64_t>(ids[r]) != turn_token) return false;
|
||||
|
||||
@@ -16439,15 +16439,18 @@ int main(int argc, char** argv) {
|
||||
// conversation, a parked one coming back, a batch slot, a borrow, another cvec) parks as before.
|
||||
bool reply_replaced = false;
|
||||
if (!from_live && !incoming && !borrow && slot_source < 0 && lent_slot < 0 && live_ok && !pin_sibling &&
|
||||
want_cvec == cvec_cached && resume > 0 && imgs_below(live_imgs, resume) == live_imgs)
|
||||
want_cvec == cvec_cached && resume > 0) {
|
||||
std::vector<int64_t> live_pictures;
|
||||
for (const ImgKey& k : live_imgs) live_pictures.push_back((int64_t) k.start);
|
||||
for (const ConvCheckpoint& c : checks)
|
||||
if ((int64_t) c.ids.size() == resume && starts_with(c.ids, c.imgs) &&
|
||||
strata::program::live_tail_is_replaced_reply(live, ids, resume, o.turn_token)) {
|
||||
strata::program::live_tail_is_replaced_reply(live, ids, resume, o.turn_token, live_pictures)) {
|
||||
reply_replaced = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (reply_replaced)
|
||||
std::fprintf(stderr, "strata serve: conversation cache: the reply this request replaces is not parked (%lld "
|
||||
std::fprintf(stderr, "[DRAFT] strata serve: conversation cache: the reply this request replaces is not parked (%lld "
|
||||
"tokens past the turn checkpoint at %lld)\n", (long long) ((int64_t) live.size() - resume),
|
||||
(long long) resume);
|
||||
// --conversation-cache-park-gain N: a park now would supersede the entry parked_prefix_tokens() reports (the copy
|
||||
|
||||
@@ -63,6 +63,11 @@ int main() {
|
||||
assert(!live_tail_is_replaced_reply(to32(cat({history, {S}})), cat({history, head}), turn, S)); ++cases;
|
||||
// the prompt ends right at the turn opening (one token past resume): no role to compare
|
||||
assert(!live_tail_is_replaced_reply(live, cat({history, {S}}), turn, S)); ++cases;
|
||||
// picture_at_or_past_checkpoint_parks: the live branch has a picture at or past resume: parked as before
|
||||
assert(!live_tail_is_replaced_reply(live, cat({history, head}), turn, S, {turn})); ++cases;
|
||||
assert(!live_tail_is_replaced_reply(live, cat({history, head}), turn, S, {2, turn + 3})); ++cases;
|
||||
// a picture before the checkpoint (in the reused history) does not stop the rule
|
||||
assert(live_tail_is_replaced_reply(live, cat({history, head}), turn, S, {2})); ++cases;
|
||||
// no turn token configured, resume 0
|
||||
assert(!live_tail_is_replaced_reply(live, cat({history, head}), turn, -1)); ++cases;
|
||||
assert(!live_tail_is_replaced_reply(live, cat({history, head}), 0, S)); ++cases;
|
||||
|
||||
Reference in new issue
Block a user