File size: 4,208 Bytes
c1e4f50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# `memory["task"]`: what the conversation is doing (design v1, cleopatra, 2026-11-12)

## Why
Held-out long chats (45 chats, 251 turns, main `9f45dc5`): first turns 93% good, later turns **39%**.
Later-turn failures: drift to a wrong-domain card 51, on topic but not the thing asked 26, repeat 20,
hedge 14, filler 12, echo 2 (churchill's scorer).

Traced cause (lincoln and cleopatra, independently): on these turns the arbiter has only two candidates,
`answers` and the greeting fallback. The wrong card is chosen inside `bot/knowledge/lookup.py:find`:
- A line is matched on **its own words first, across all domains**; the chat is consulted
  (`_following_on`) only when nothing matched at all.
- `_following_on` carries the **last line's** words only (`leans_on`), not what the chat is about.
  #multi-turn showed a wider window alone changes nothing (LOOK_BACK: 0 of 532 turns).

Example: puppy chat, "a cocker spaniel", then "how do i stop her biting". Understanding has
`topic=pets`, `followup=True`, own topic `None`; the lookup still returns the insect-bite card.
With "puppy" in the line, the right mouthing card is found.

## What it is
One dict, written in `observe` by one module (`bot/memory/task.py`), read by everyone:

```python
memory["task"] = {
  "goal":    "a present for dad",   # the ask that opened it, as a short phrase
  "topic":   "shopping",            # topic id when opened (+ "topics": [...] if several)
  "subject": "present",             # the head thing the chat is about
  "kind":    None,                  # broader word for the subject when known: spaniel -> dog
  "details": {                      # what the person added since; values in their words
     "who": "dad", "age": "60", "likes": ["fishing", "gardening"], "budget": "£50",
     "has": ["mince", "onion", "tomatoes"], "not": ["pasta"], "when": "may", "where": "porto"},
  "offered": {"items": ["Arrival", "Contact", "Moon"], "turn": 3},   # what the bot named/listed
  "mood":    None,                  # "low" after bad news, kept a few turns
  "opened":  2, "updated": 6,       # turn indexes
}
```

## Life cycle
- **Open**: a line that asks or plans with a subject of its own (not a follow-up). Replaces the old task.
- **Update**: a follow-up, a bare detail ("budget is about 50 quid", "shes 9 weeks", "its a fan oven"),
  or a correction ("i meant porto", "no pasta left") writes into `details`; a correction overwrites.
- **Keep**: a line with no strong subject of its own (topic from a brush word only, `topic_is_a_brush`)
  does not replace it.
- **Close**: `change_of_subject`, a goodbye, or a new strong subject.
- **Offered**: set in `after()` from the chosen reply: italic titles, "X, Y or Z" lists, named dishes.

Built only from readings that already exist (`understood`: topic, subject, followup, leans_on,
numbers, excludes, change_of_subject; `user`/`others`; limits). No new parsing where one exists.

## Who reads it (each a separate small PR)
1. **The gate (lookup, #answers/#understanding, @lincoln)**: on a line with no strong subject of its
   own, prefer cards in `task.topic`'s domains, and read the line again with `task.subject` in it
   before taking an off-task card. A prototype of half of this (domain prior only) moved 4 of 152
   held-out turns, 3 better and 1 worse.
2. **What the bot offered (#conversation)**: "another", "that one", "the second one", "what else",
   "seen it", "something funnier" resolve against `task.offered`.
3. **Details in answers and recall (#conversation/#answers)**: "what did i say i had in", "his age";
   the budget/ages/constraints are applied to the next card (the gift at £50, the kids' dinner).
4. **Mood (#conversation)**: after bad news, a plain detail ("4 years") is read in that light.

## How it lands (small steps; ~4 h per merge)
- **PR 1, no reply changes**: `bot/memory/task.py` (observe + after), README key row, tests,
  and `tools/task_trace.py` (prints the task per turn for any chat, so every reviewer can see it).
  Proof: `compare.py --sample 0` shows no reply changed.
- PRs 2-4 then read it, one class at a time. Each shows `--variants`, at least one 5+ turn chat,
  and churchill's held-out later-turn score vs main.