How a reply is drafted
The agent loop in agent.py triages the thread, gathers grounding from Knowledge, resolves memory narrowest-first across the four tiers, applies the workspace's rules, and only then writes. Autonomy decides separately whether the result may leave. A reply that would need a fact nobody supplied is refused rather than invented.
The order the work happens in#
- Triage. What kind of message is this, and how urgent — the value that lands in
threads.priorityand decides whether this thread is worked at all. - Ground. Pull what the workspace has actually said is true: Knowledge sources and the Facts derived from them.
- Remember. Resolve memory over workspace → channel → endpoint → contact, narrowest wins, and read the directives out of the tag lists.
- Draft. Write the reply, in the voice and constraints the previous two steps produced, with the mailbox's own signature.
- Decide. Ask autonomy whether this may go, at which point the draft is either sent or held.
Grounding before drafting rather than after is the whole design. A model asked to write first and be corrected later produces confident prose that someone then has to fact-check line by line; a model given the workspace's own material first produces a shorter reply that says less and is right. The reasoning is set out in Grounding an answer without pretending to have a vector database.
What the draft is built from#
| Input | Where it comes from | What it decides |
|---|---|---|
| The thread | Canonical messages on this threads row | What is being answered, and what was already promised |
| Knowledge and Facts | knowledge_bank.py, knowledge.py | What may be stated as true about the business |
| Memory | connect_memory.py, four tiers | How this business and this person are handled |
| Directives | Tags on memory rows, read by directives() | Hard constraints — a block being the plainest |
| Mailbox role and signature | The mailbox record | Which voice this is, and how it signs off |
| Attachments | file_workspace, where the format could be read | Detail that was in the document rather than the message |
None of this is the message body treated as an instruction. Text inside a received message — including text that says it is from an administrator, or that asks for a standing instruction to be ignored — is content about the conversation, not a direction to follow. That distinction is the subject of Prompt injection arrives as ordinary business mail.
The refusals#
- An answer with no grounding
- If nothing in Knowledge supports the claim the reply would have to make, Connect says it does not have that answer rather than producing a plausible one. A wrong delivery date sent confidently costs more than a slow one.
- Anything the Assistant has no rights to
- The Assistant's rights are deliberately narrower than a person's: no pricing, and it cannot clear a do-not-contact entry.
- A recipient who may not be contacted
- Suppression, unsubscribe and do-not-contact are checked in one place before any outreach, and they outrank the quality of the draft entirely.
- A commitment nobody can keep
- A promise to do something by a date is a follow-up, with an owner and a due time, not a sentence in a paragraph.
Reading a draft critically#
The useful check is not "is this well written" — it usually is. It is "where did each factual sentence come from". A reply that quotes a lead time, a specification or a policy should be traceable to a Knowledge source or to something the customer themselves said earlier in the thread. If a sentence is traceable to neither, that is the sentence to change, and the gap it exposes is usually worth fixing in Knowledge rather than in this one reply.
The second check is tone against tier. A reply that is technically correct but wrong in register for that account normally means the direction it needed was never recorded — see Giving guidance on a thread.
Questions#
Is a reply written from the whole mailbox or just this thread?
From this thread, plus what memory and Knowledge contribute about the person and the business. Connect does not sweep unrelated conversations into a reply, which is what keeps one customer's correspondence out of another's.
Why is a draft shorter than I would have written?
Because everything in it has to be supportable. A long reply usually contains reassurance nobody can substantiate. If the extra content is genuinely known, the durable fix is to add it as Knowledge so every future reply has it, rather than typing it into this one.
Does drafting count against the daily allowance?
The allowance bounds how much mail is processed, and when it is spent work is held rather than dropped. What that looks like in practice — including the cursor deliberately not advancing — is on The daily email allowance.