Skip to content

Latest commit

 

History

History
144 lines (107 loc) · 3.89 KB

File metadata and controls

144 lines (107 loc) · 3.89 KB

中文 | English

Agent Thread Assistant

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:

  1. sync recent inbox state
  2. choose a relevant thread
  3. inspect the full local thread
  4. draft a reply through ReplyDraft
  5. compile the reply with mailcli reply --dry-run

The example script is:

  • examples/go/agent_thread_assistant

What It Demonstrates

  1. Running mailcli sync to refresh a local index
  2. Using mailcli threads to rank thread candidates
  3. Using mailcli thread to load the selected local conversation
  4. Choosing the latest local message as the reply target
  5. Generating a ReplyDraft instead of raw MIME
  6. Compiling the draft with mailcli reply --dry-run

Inbox-Backed Example

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."

Zero-Network Fixture Example

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 invoice

This 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.

Existing Local Index Example

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."

External Provider Mode

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_provider

The external provider receives a JSON payload that includes:

  • selection
  • thread_summaries
  • thread_messages
  • latest_message
  • wants_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.

Reply Draft Strategy

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-To
  • References
  • default reply subject
  • default reply recipient when to is 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.

Output Shape

The Go example prints one JSON report that includes:

  • sync
  • selection
  • thread_summaries
  • thread_messages
  • latest_message
  • analysis
  • optional reply

Why This Example Exists

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: