Ask: Use case: Request-response. Response: Future you can await.
Use Tell when you don’t need a reply: logging, notifications, commands that trigger side effects. Use Ask when
you need a result: queries, computations, or any flow that depends on the response.
The Ask timeout reaches the actor
The timeout of an Ask is not only how long the caller waits. The actor knows the moment the caller stops waiting: the
ask timeout, or the deadline of the caller’s context when that comes first.
An Ask that expired before its turn is skipped. When the actor dequeues an Ask whose caller already gave up, in
the mailbox or in the stash, it does not hand it to Receive. Under load this keeps a slow actor from spending its
turns on answers nobody reads, and a caller that timed out and retried does not get its work done twice.
Context() ends with the Ask. Inside Receive, ctx.Context() carries that deadline, so a handler that passes
it to a database query or an HTTP call stops when nobody waits for the answer. The context also ends when Receive
returns.
A timeout is ErrRequestTimeout everywhere.errors.Is(err, errors.ErrRequestTimeout) is true whether the actor
is on the calling node or on another one.
A Tell is not affected: it is handled whenever its turn comes, and its context carries no deadline of its own.
An Ask that is already in Receive when its caller gives up still runs to the end, unless the handler watches
ctx.Context(). The caller sees ErrRequestTimeout while the work may have been done, so a handler whose callers
retry must be idempotent.
Message types
All message-passing APIs accept any. You can send:
Plain Go structs (with CBOR serialization when remote)
The framework handles serialization when the target is on another node. Locally, messages are passed by reference
without serialization.
Keep messages pure
Treat every message as a pure data struct: fields should carry only values the receiver needs to process the message
(IDs, payloads, commands, query parameters). Prefer immutable messages: do not mutate a message after it has been
sent, and do not share mutable references between actors through message fields.
Do not embed concurrency primitives in messages to collect a reply: especially chan fields, mutexes, wait
groups, or callbacks. That couples the sender’s goroutine to the actor’s mailbox, breaks the actor model, and can
cause races, deadlocks, or unpredictable behavior when messages are stashed, forwarded, retried, or sent remotely
(channels and function values do not serialize).
Messages between a specific sender-receiver pair are delivered in the order they were sent (FIFO). This follows from the
mailbox being a FIFO queue and the single-threaded processing guarantee per actor.
Sender context
In Receive, you can access the sender via ctx.Sender(). It returns a *PID or nil (e.g., for scheduled messages
or when the sender is unknown). Use ctx.Sender().Path() when you need the sender’s address for a reply.
ReceiveContext messaging methods
Inside Receive, the ReceiveContext provides these messaging operations:
Tell: Fire-and-forget. Does not block.
Ask: Request-response. Blocks until reply or timeout.
Response: Reply to an Ask. Call exactly once per Ask message.
Request: Non-blocking Ask; use continuations for the reply.
PipeTo: Run task asynchronously; deliver result to to. See PipeTo.
PipeToName: Same, target by name.
Use Sender() to get the sender’s PID when replying. Use ActorSystem().ActorOf(ctx, name) to resolve an actor by name
before sending.
No shared state
Actors never share memory. All communication is through pure, preferably immutable message structs: not shared channels,
mutable bags of state, or callbacks stuffed into the payload. That discipline eliminates whole classes of concurrency
bugs and keeps behavior predictable under remoting, supervision, and mailbox scheduling.
{"docsConfig":{"theme":"aspen","$schema":"https://mintlify.com/docs.json","name":"GoAkt","description":"Distributed actor framework for Go, inspired by Erlang and Akka. Build reactive and distributed systems with typed actor messages.","colors":{"primary":"#2563EB","light":"#3B82F6","dark":"#1D4ED8"},"logo":{"light":"https://mintcdn.com/goakt/mo16dXRmmfkLB1TY/assets/goakt-wordmark-light.svg?fit=max\u0026auto=format\u0026n=mo16dXRmmfkLB1TY\u0026q=85\u0026s=15e88a1da193b22f26e0a895bd0a9f41","dark":"https://mintcdn.com/goakt/mo16dXRmmfkLB1TY/assets/goakt-wordmark-dark.svg?fit=max\u0026auto=format\u0026n=mo16dXRmmfkLB1TY\u0026q=85\u0026s=61009011224a9ae20d0cc10a44e6240c","href":"https://goakt.dev"},"favicon":"https://mintcdn.com/goakt/XmpAdEFeAelYLko1/assets/goakt-icon.svg?fit=max\u0026auto=format\u0026n=XmpAdEFeAelYLko1\u0026q=85\u0026s=c5016527b60a39997f806335a9e66613","appearance":{"default":"dark"},"navbar":{"links":[{"icon":"package","href":"https://pkg.go.dev/github.com/tochemey/goakt/v4","label":"API Reference"},{"icon":"github","href":"https://github.com/tochemey/goakt","label":"GitHub"}]},"footer":{"socials":{"github":"https://github.com/tochemey/goakt"}},"seo":{"metatags":{"canonical":"https://docs.goakt.dev"}},"fonts":{"heading":{"family":"Inter"},"body":{"family":"Inter"}},"icons":{"library":"lucide"},"styling":{"codeblocks":{"theme":"night-owl"},"latex":false},"contextual":{"options":["copy","view","claude","mcp","vscode"],"display":"header"},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"goakt","hasAudioNarration":false,"actualSubdomain":"goakt","customDomains":["docs.goakt.dev"],"gitSource":{"type":"github","owner":"tochemey","repo":"goakt","deployBranch":"main","contentDirectory":"docs","isPrivate":true,"mountPath":"","label":""},"entitlements":{},"buildId":"6ae527ab24f1a32e1b87ad63","clientVersion":"0.0.4142","searchFilterCounts":[{"language":"default","tag":"Guides","count":46},{"language":"default","tag":"Actors","count":19},{"language":"default","tag":"Advanced","count":8},{"language":"default","tag":"Contributing","count":8},{"language":"default","tag":"Clustering","count":7},{"language":"default","tag":"Reference","count":6},{"language":"default","tag":"Grains","count":5},{"language":"default","tag":"Architecture","count":3},{"language":"default","tag":"Remoting","count":2},{"language":"default","tag":"AI Agents","count":1}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":"/* cyrillic-ext */\n@font-face {\n font-family: 'IBM Plex Mono';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/ibmplexmono/v23/-F63fjptAgt5VM-kVkqdyU8n1iIq129k.woff2) format('woff2');\n unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;\n}\n/* cyrillic */\n@font-face {\n font-family: 'IBM Plex Mono';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/ibmplexmono/v23/-F63fjptAgt5VM-kVkqdyU8n1isq129k.woff2) format('woff2');\n unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;\n}\n/* symbols2 */\n@font-face {\n font-family: 'IBM Plex Mono';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/ibmplexmono/v23/-F63fjptAgt5VM-kVkqdyU8n1pUL8lJdhg.woff2) format('woff2');\n unicode-range: U+2000-2001, U+2004-2008, U+200A, U+23B8-23BD, U+2500-259F;\n}\n/* vietnamese */\n@font-face {\n font-family: 'IBM Plex Mono';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/ibmplexmono/v23/-F63fjptAgt5VM-kVkqdyU8n1iAq129k.woff2) format('woff2');\n unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;\n}\n/* latin-ext */\n@font-face {\n font-family: 'IBM Plex Mono';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/ibmplexmono/v23/-F63fjptAgt5VM-kVkqdyU8n1iEq129k.woff2) format('woff2');\n unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;\n}\n/* latin */\n@font-face {\n font-family: 'IBM Plex Mono';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/ibmplexmono/v23/-F63fjptAgt5VM-kVkqdyU8n1i8q1w.woff2) format('woff2');\n unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;\n}\n/* cyrillic-ext */\n@font-face {\n font-family: 'IBM Plex Mono';\n font-style: normal;\n font-weight: 500;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/ibmplexmono/v23/-F6qfjptAgt5VM-kVkqdyU8n3twJwl1FgtIU.woff2) format('woff2');\n unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;\n}\n/* cyrillic */\n@font-face {\n font-family: 'IBM Plex Mono';\n font-style: normal;\n font-weight: 500;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/ibmplexmono/v23/-F6qfjptAgt5VM-kVkqdyU8n3twJwlRFgtIU.woff2) format('woff2');\n unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;\n}\n/* symbols2 */\n@font-face {\n font-family: 'IBM Plex Mono';\n font-style: normal;\n font-weight: 500;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/ibmplexmono/v23/-F6qfjptAgt5VM-kVkqdyU8n3twJwupkp-8tFQ.woff2) format('woff2');\n unicode-range: U+2000-2001, U+2004-2008, U+200A, U+23B8-23BD, U+2500-259F;\n}\n/* vietnamese */\n@font-face {\n font-family: 'IBM Plex Mono';\n font-style: normal;\n font-weight: 500;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/ibmplexmono/v23/-F6qfjptAgt5VM-kVkqdyU8n3twJwl9FgtIU.woff2) format('woff2');\n unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;\n}\n/* latin-ext */\n@font-face {\n font-family: 'IBM Plex Mono';\n font-style: normal;\n font-weight: 500;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/ibmplexmono/v23/-F6qfjptAgt5VM-kVkqdyU8n3twJwl5FgtIU.woff2) format('woff2');\n unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;\n}\n/* latin */\n@font-face {\n font-family: 'IBM Plex Mono';\n font-style: normal;\n font-weight: 500;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/ibmplexmono/v23/-F6qfjptAgt5VM-kVkqdyU8n3twJwlBFgg.woff2) format('woff2');\n unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;\n}\ncode,kbd,samp,pre,pre.shiki{font-family:\"IBM Plex Mono\", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace!important}img[src$=\"goakt-wordmark-light.svg\"],img[src$=\"goakt-wordmark-dark.svg\"]{height:2.25rem}h1,h2,h3{letter-spacing:-0.02em}#content p,#content ul,#content ol,.mdx-content p,.mdx-content ul,.mdx-content ol,.prose p,.prose ul,.prose ol,#content-container p,#content-container ul,#content-container ol{font-size:0.925rem;line-height:1.7}#content li,.mdx-content li,.prose li,#content-container li{margin-top:0.3rem;margin-bottom:0.3rem}#content :not(pre)>code,.mdx-content :not(pre)>code,.prose :not(pre)>code,#content-container :not(pre)>code{font-size:0.82em;padding:0.1em 0.3em}pre.shiki{line-height:1.4rem;font-size:0.8rem}"}],"page":{"pagePath":"actor/messaging","slug":"/actor/messaging","pageMetadata":{"title":"Messaging","description":"Tell, Ask, and PipeTo for actor communication.","sidebarTitle":"Messaging","href":"/actor/messaging"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Tell, Ask, and PipeTo for actor communication.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{Heading,Warning}=_components;if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`2`,id:`tell-vs-ask`,children:`Tell vs Ask`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Tell`}),`: Use case: Fire-and-forget. Response: None.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Ask`}),`: Use case: Request-response. Response: Future you can await.`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`Use `,_jsx(_components.strong,{children:`Tell`}),` when you don’t need a reply: logging, notifications, commands that trigger side effects. Use `,_jsx(_components.strong,{children:`Ask`}),` when\nyou need a result: queries, computations, or any flow that depends on the response.`]}),`\n`,_jsx(Heading,{level:`3`,id:`the-ask-timeout-reaches-the-actor`,children:`The Ask timeout reaches the actor`}),`\n`,_jsx(_components.p,{children:`The timeout of an Ask is not only how long the caller waits. The actor knows the moment the caller stops waiting: the\nask timeout, or the deadline of the caller’s context when that comes first.`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`An Ask that expired before its turn is skipped.`}),` When the actor dequeues an Ask whose caller already gave up, in\nthe mailbox or in the stash, it does not hand it to `,_jsx(_components.code,{children:`Receive`}),`. Under load this keeps a slow actor from spending its\nturns on answers nobody reads, and a caller that timed out and retried does not get its work done twice.`]}),`\n`,_jsxs(_components.li,{children:[_jsxs(_components.strong,{children:[_jsx(_components.code,{children:`Context()`}),` ends with the Ask.`]}),` Inside `,_jsx(_components.code,{children:`Receive`}),`, `,_jsx(_components.code,{children:`ctx.Context()`}),` carries that deadline, so a handler that passes\nit to a database query or an HTTP call stops when nobody waits for the answer. The context also ends when `,_jsx(_components.code,{children:`Receive`}),`\nreturns.`]}),`\n`,_jsxs(_components.li,{children:[_jsxs(_components.strong,{children:[`A timeout is `,_jsx(_components.code,{children:`ErrRequestTimeout`}),` everywhere.`]}),` `,_jsx(_components.code,{children:`errors.Is(err, errors.ErrRequestTimeout)`}),` is true whether the actor\nis on the calling node or on another one.`]}),`\n`]}),`\n`,_jsx(_components.p,{children:`A Tell is not affected: it is handled whenever its turn comes, and its context carries no deadline of its own.`}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`An Ask that is already in `,_jsx(_components.code,{children:`Receive`}),` when its caller gives up still runs to the end, unless the handler watches\n`,_jsx(_components.code,{children:`ctx.Context()`}),`. The caller sees `,_jsx(_components.code,{children:`ErrRequestTimeout`}),` while the work may have been done, so a handler whose callers\nretry must be idempotent.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`message-types`,children:`Message types`}),`\n`,_jsxs(_components.p,{children:[`All message-passing APIs accept `,_jsx(_components.code,{children:`any`}),`. You can send:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Plain Go structs (with CBOR serialization when remote)`}),`\n`,_jsx(_components.li,{children:`Protocol buffer messages (default ProtoSerializer)`}),`\n`,_jsx(_components.li,{children:`Any type registered with the serializer`}),`\n`]}),`\n`,_jsx(_components.p,{children:`The framework handles serialization when the target is on another node. Locally, messages are passed by reference\nwithout serialization.`}),`\n`,_jsx(Heading,{level:`3`,id:`keep-messages-pure`,children:`Keep messages pure`}),`\n`,_jsxs(_components.p,{children:[`Treat every message as a `,_jsx(_components.strong,{children:`pure data struct`}),`: fields should carry only values the receiver needs to process the message\n(IDs, payloads, commands, query parameters). Prefer `,_jsx(_components.strong,{children:`immutable`}),` messages: do not mutate a message after it has been\nsent, and do not share mutable references between actors through message fields.`]}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Do `,_jsx(_components.strong,{children:`not`}),` embed concurrency primitives in messages to collect a reply: especially `,_jsx(_components.code,{children:`chan`}),` fields, mutexes, wait\ngroups, or callbacks. That couples the sender’s goroutine to the actor’s mailbox, breaks the actor model, and can\ncause races, deadlocks, or unpredictable behavior when messages are stashed, forwarded, retried, or sent remotely\n(channels and function values do not serialize).`]})}),`\n`,_jsxs(_components.p,{children:[`When you need a response, use `,_jsx(_components.strong,{children:`Ask`}),` and reply with `,_jsx(_components.code,{children:`Response`}),`, or send a separate reply message with `,_jsx(_components.strong,{children:`Tell`}),`. See\n`,_jsx(_components.a,{href:`#tell-vs-ask`,children:`Tell vs Ask`}),` and `,_jsx(_components.a,{href:`#receivecontext-messaging-methods`,children:`ReceiveContext messaging methods`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`message-ordering`,children:`Message ordering`}),`\n`,_jsx(_components.p,{children:`Messages between a specific sender-receiver pair are delivered in the order they were sent (FIFO). This follows from the\nmailbox being a FIFO queue and the single-threaded processing guarantee per actor.`}),`\n`,_jsx(Heading,{level:`2`,id:`sender-context`,children:`Sender context`}),`\n`,_jsxs(_components.p,{children:[`In `,_jsx(_components.code,{children:`Receive`}),`, you can access the sender via `,_jsx(_components.code,{children:`ctx.Sender()`}),`. It returns a `,_jsx(_components.code,{children:`*PID`}),` or `,_jsx(_components.code,{children:`nil`}),` (e.g., for scheduled messages\nor when the sender is unknown). Use `,_jsx(_components.code,{children:`ctx.Sender().Path()`}),` when you need the sender’s address for a reply.`]}),`\n`,_jsx(Heading,{level:`2`,id:`receivecontext-messaging-methods`,children:`ReceiveContext messaging methods`}),`\n`,_jsxs(_components.p,{children:[`Inside `,_jsx(_components.code,{children:`Receive`}),`, the `,_jsx(_components.code,{children:`ReceiveContext`}),` provides these messaging operations:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Tell`}),`: Fire-and-forget. Does not block.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Ask`}),`: Request-response. Blocks until reply or timeout.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Response`}),`: Reply to an Ask. Call exactly once per Ask message.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Request`}),`: Non-blocking Ask; use continuations for the reply.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`PipeTo`}),`: Run task asynchronously; deliver result to `,_jsx(_components.code,{children:`to`}),`. See `,_jsx(_components.a,{href:`/actor/pipeto`,children:`PipeTo`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`PipeToName`}),`: Same, target by name.`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`Use `,_jsx(_components.code,{children:`Sender()`}),` to get the sender’s PID when replying. Use `,_jsx(_components.code,{children:`ActorSystem().ActorOf(ctx, name)`}),` to resolve an actor by name\nbefore sending.`]}),`\n`,_jsx(Heading,{level:`2`,id:`no-shared-state`,children:`No shared state`}),`\n`,_jsx(_components.p,{children:`Actors never share memory. All communication is through pure, preferably immutable message structs: not shared channels,\nmutable bags of state, or callbacks stuffed into the payload. That discipline eliminates whole classes of concurrency\nbugs and keeps behavior predictable under remoting, supervision, and mailbox scheduling.`})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":{"theme":"night-owl"},"config":{},"pageMetadata":{"title":"Messaging","description":"Tell, Ask, and PipeTo for actor communication.","sidebarTitle":"Messaging","href":"/actor/messaging"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Tell vs Ask","slug":"tell-vs-ask","depth":2,"children":[{"title":"The Ask timeout reaches the actor","slug":"the-ask-timeout-reaches-the-actor","depth":3,"children":[]}]},{"title":"Message types","slug":"message-types","depth":2,"children":[{"title":"Keep messages pure","slug":"keep-messages-pure","depth":3,"children":[]}]},{"title":"Message ordering","slug":"message-ordering","depth":2,"children":[]},{"title":"Sender context","slug":"sender-context","depth":2,"children":[]},{"title":"ReceiveContext messaging methods","slug":"receivecontext-messaging-methods","depth":2,"children":[]},{"title":"No shared state","slug":"no-shared-state","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"goakt","siteName":"GoAkt","title":"Messaging - GoAkt","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-02T18:14:27.124Z","originalFileLocation":"actor/messaging.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"dark\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Tell, Ask, and PipeTo for actor communication.\">\u003cmeta data-mint-head name=\"application-name\" content=\"GoAkt\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/goakt/GNwc7CNvyGqibGSt/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/goakt/GNwc7CNvyGqibGSt/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/goakt/GNwc7CNvyGqibGSt/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/goakt/GNwc7CNvyGqibGSt/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/goakt/GNwc7CNvyGqibGSt/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/goakt/GNwc7CNvyGqibGSt/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/goakt/GNwc7CNvyGqibGSt/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/goakt/GNwc7CNvyGqibGSt/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/goakt/GNwc7CNvyGqibGSt/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Messaging - GoAkt\">\u003cmeta data-mint-head property=\"og:description\" content=\"Tell, Ask, and PipeTo for actor communication.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"GoAkt\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.goakt.dev/actor/messaging\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://goakt.mintlify.site/_mintlify/api/og/v2?division=Actors\u0026amp;title=Messaging\u0026amp;description=Tell%2C+Ask%2C+and+PipeTo+for+actor+communication.\u0026amp;theme=a41ee93b0e26ef163e6ad555\u0026amp;signature=9a1a4d84c632e312baa23ce53c0831186883408e691eef94364abf9f94b66fab\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Messaging - GoAkt\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Tell, Ask, and PipeTo for actor communication.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://goakt.mintlify.site/_mintlify/api/og/v2?division=Actors\u0026amp;title=Messaging\u0026amp;description=Tell%2C+Ask%2C+and+PipeTo+for+actor+communication.\u0026amp;theme=a41ee93b0e26ef163e6ad555\u0026amp;signature=9a1a4d84c632e312baa23ce53c0831186883408e691eef94364abf9f94b66fab\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/goakt/GNwc7CNvyGqibGSt/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"GoAkt\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#2563EB\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.goakt.dev/actor/messaging\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/actor/messaging.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.goakt.dev/#organization\",\"name\":\"GoAkt\",\"url\":\"https://docs.goakt.dev\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/goakt/mo16dXRmmfkLB1TY/assets/goakt-wordmark-light.svg?fit=max\u0026auto=format\u0026n=mo16dXRmmfkLB1TY\u0026q=85\u0026s=15e88a1da193b22f26e0a895bd0a9f41\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.goakt.dev#website\",\"name\":\"GoAkt\",\"url\":\"https://docs.goakt.dev\",\"publisher\":{\"@id\":\"https://docs.goakt.dev/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.goakt.dev/actor/messaging#webpage\",\"url\":\"https://docs.goakt.dev/actor/messaging\",\"name\":\"Messaging\",\"description\":\"Tell, Ask, and PipeTo for actor communication.\",\"dateModified\":\"2026-10-02T18:14:27.124Z\",\"isPartOf\":{\"@id\":\"https://docs.goakt.dev#website\"},\"breadcrumb\":{\"@id\":\"https://docs.goakt.dev/actor/messaging#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.goakt.dev/actor/messaging#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Actors\",\"item\":\"https://docs.goakt.dev/actor/actor-model\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Messaging\",\"item\":\"https://docs.goakt.dev/actor/messaging\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.goakt.dev/actor/messaging#article\",\"headline\":\"Messaging\",\"name\":\"Messaging\",\"description\":\"Tell, Ask, and PipeTo for actor communication.\",\"url\":\"https://docs.goakt.dev/actor/messaging\",\"mainEntityOfPage\":{\"@id\":\"https://docs.goakt.dev/actor/messaging#webpage\"},\"dateModified\":\"2026-10-02T18:14:27.124Z\",\"publisher\":{\"@id\":\"https://docs.goakt.dev/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.goakt.dev#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"GoAkt\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"GoAkt\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/actor/messaging.md","siteName":"GoAkt","nav":{"global":null,"tabs":[{"tab":"Guides","icon":"book-open","groups":[{"group":"Quickstart","icon":"play","pages":[{"title":"Quickstart","sidebarTitle":"Quickstart","href":"/getting-started/quickstart"}]},{"group":"Actors","icon":"users","pages":[{"title":"Actor Model","sidebarTitle":"Actor Model","href":"/actor/actor-model"},{"title":"Actor System","sidebarTitle":"Actor System","href":"/actor/actor-system"},{"title":"PID","sidebarTitle":"PID","href":"/actor/pid"},{"title":"Actor Lifecycle","description":"Spawn, stop, and lifecycle events.","sidebarTitle":"Actor Lifecycle","href":"/actor/lifecycle"},{"title":"Messaging","sidebarTitle":"Messaging","href":"/actor/messaging"},{"title":"Mailboxes","description":"Choose how an actor queues incoming messages with the built-in mailboxes or a custom one.","sidebarTitle":"Mailboxes","href":"/actor/mailboxes"},{"title":"PipeTo","sidebarTitle":"PipeTo","href":"/actor/pipeto"},{"title":"Stashing","sidebarTitle":"Stashing","href":"/actor/stashing"},{"title":"Reentrancy","sidebarTitle":"Reentrancy","href":"/actor/reentrancy"},{"title":"Scheduling","sidebarTitle":"Scheduling","href":"/actor/scheduling"},{"title":"Supervision","sidebarTitle":"Supervision","href":"/actor/supervision"},{"title":"Death Watch","sidebarTitle":"Death Watch","href":"/actor/death-watch"},{"title":"Behaviors","sidebarTitle":"Behaviors","href":"/actor/behaviors"},{"title":"Location Transparency","sidebarTitle":"Location Transparency","href":"/actor/location-transparency"},{"title":"Passivation","sidebarTitle":"Passivation","href":"/actor/passivation"},{"title":"Relocation","sidebarTitle":"Relocation","href":"/actor/relocation"},{"title":"Cluster Singletons","sidebarTitle":"Cluster Singletons","href":"/actor/singletons"},{"title":"Routers","sidebarTitle":"Routers","href":"/actor/routers"},{"title":"TestKit","sidebarTitle":"TestKit","href":"/actor/testkit"}]},{"group":"Grains","icon":"box","pages":[{"title":"Grains","sidebarTitle":"Overview","href":"/grains/overview"},{"title":"Grain Reentrancy","sidebarTitle":"Reentrancy","href":"/grains/reentrancy"},{"title":"Grain PipeTo","sidebarTitle":"PipeTo","href":"/grains/pipeto"},{"title":"Grain Timers","sidebarTitle":"Timers","href":"/grains/timers"},{"title":"Grain Scheduling","sidebarTitle":"Scheduling","href":"/grains/scheduling"}]},{"group":"AI Agents","icon":"bot","pages":[{"title":"AI Agents","sidebarTitle":"Overview","href":"/ai-agents/overview"}]},{"group":"Remoting","icon":"radio","pages":[{"title":"Remoting","sidebarTitle":"Overview","href":"/advanced/remoting"},{"title":"Serialization","sidebarTitle":"Serialization","href":"/advanced/serialization"}]},{"group":"Clustering","icon":"network","pages":[{"title":"Clustering","sidebarTitle":"Overview","href":"/clustering/overview"},{"title":"Placement","sidebarTitle":"Placement","href":"/clustering/placement"},{"title":"Service Discovery","sidebarTitle":"Service Discovery","href":"/clustering/service-discovery"},{"title":"Partition Hashing","sidebarTitle":"Partition Hashing","href":"/clustering/partition-hashing"},{"title":"Multi-Datacenter","sidebarTitle":"Multi-Datacenter","href":"/clustering/multi-datacenter"},{"title":"Point-to-Point","sidebarTitle":"Reliable Point-to-Point","href":"/clustering/reliable-delivery/point-to-point"},{"title":"Work-Pulling","sidebarTitle":"Work-Pulling","href":"/clustering/reliable-delivery/work-pulling"}]},{"group":"Advanced","icon":"zap","pages":[{"title":"PubSub","sidebarTitle":"PubSub","href":"/advanced/pubsub"},{"title":"Reactive Streams","sidebarTitle":"Reactive Streams","href":"/advanced/streams"},{"title":"Distributed Data (CRDTs)","sidebarTitle":"Distributed Data","href":"/advanced/distributed-data"},{"title":"Client","sidebarTitle":"Client","href":"/advanced/client"},{"title":"Extensions and Dependencies","sidebarTitle":"Extensions and Dependencies","href":"/advanced/extensions-and-dependencies"},{"title":"Coordinated Shutdown","sidebarTitle":"Coordinated Shutdown","href":"/advanced/coordinated-shutdown"},{"title":"Observability","sidebarTitle":"Observability","href":"/advanced/observability"},{"title":"Event Streams","sidebarTitle":"Event Streams","href":"/advanced/event-streams"}]},{"group":"Architecture","icon":"blocks","pages":[{"title":"Architecture Overview","sidebarTitle":"Overview","href":"/architecture/overview"},{"title":"Code Map","sidebarTitle":"Code Map","href":"/architecture/code-map"},{"title":"Design Decisions","sidebarTitle":"Design Decisions","href":"/architecture/design-decisions"}]}]},{"tab":"Reference","icon":"book","pages":[{"title":"Reference","href":"/reference/glossary"}]},{"tab":"Contributing","icon":"hand-heart","pages":[{"title":"Contributing","href":"/contributing/overview"}]},{"tab":"eGo","icon":"layers","pages":[{"title":"eGo","href":"/meta-framework/ego"}]}]},"basePath":"","title":"Messaging - GoAkt","buildId":"dpl_G2Qd45vZZ7MkBiGF9yYx8ZsbbKXX","deploymentId":"dpl_G2Qd45vZZ7MkBiGF9yYx8ZsbbKXX","dynamics":[],"chunks":[]}