中文 | English
This example shows a fuller agent workflow built on top of mailcli local indexing and thread navigation.
It is meant for developers who want to model the common agent loop:
- sync recent inbox state
- choose a relevant thread
- inspect the full local thread
- draft a reply through
ReplyDraft - compile the reply with
mailcli reply --dry-run
The example script is:
examples/go/agent_thread_assistant
- Running
mailcli syncto refresh a local index - Using
mailcli threadsto rank thread candidates - Using
mailcli threadto load the selected local conversation - Choosing the latest local message as the reply target
- Generating a
ReplyDraftinstead of raw MIME - Compiling the draft with
mailcli reply --dry-run
go run ./examples/go/agent_thread_assistant \
--mailcli-bin ./mailcli \
--config ~/.config/mailcli/config.yaml \
--account work \
--index /tmp/mailcli-index.json \
--query invoice \
--from-address support@nono.im \
--reply-text "Thanks for your email."go run ./examples/go/agent_thread_assistant \
--mailcli-bin ./mailcli \
--config examples/config/fixtures-dir.yaml \
--account fixtures \
--index /tmp/mailcli-fixtures-index.json \
--sync-limit 0 \
--query invoiceThis uses the built-in dir driver to run the normal sync -> threads -> thread loop against the repository fixture corpus. Here --sync-limit 0 tells the Go example to call mailcli sync --limit 0 instead of truncating the initial sync pass.
go run ./examples/go/agent_thread_assistant \
--mailcli-bin ./mailcli \
--index /tmp/mailcli-index.json \
--skip-sync \
--thread-id "<root@example.com>" \
--from-address support@nono.im \
--reply-text "Thanks for your email."You can also delegate the thread analysis step to your own script or agent runtime:
go run ./examples/go/agent_thread_assistant \
--mailcli-bin ./mailcli \
--index /tmp/mailcli-index.json \
--skip-sync \
--thread-id "<root@example.com>" \
--from-address support@nono.im \
--agent-provider external \
--provider-command ./my_providerThe external provider receives a JSON payload that includes:
selectionthread_summariesthread_messageslatest_messagewants_reply
If it returns:
{
"decision": "draft_reply",
"summary": "Short analysis",
"reply_text": "Thanks for your email."
}the example will compile a reply dry-run automatically.
When --config is present, the example prefers reply_to_id using the latest local message id. That lets mailcli reply re-fetch the original raw message and derive:
In-Reply-ToReferences- default reply subject
- default reply recipient when
tois omitted
When --skip-sync is used without --config, the example falls back to a local-only draft using:
reply_to_message_id- local
references - local subject
This keeps the example usable even when developers only have an existing local index snapshot.
The Go example prints one JSON report that includes:
syncselectionthread_summariesthread_messageslatest_messageanalysis- optional
reply
The minimal inbox example is useful for single-message analysis.
This thread example is for the more realistic agent case where the model needs local memory, thread-level context, and a stable reply boundary.
Related docs: