stdout is the transport
This is the one thing to get right on stdio. The protocol runs over stdout, so anything else written there corrupts the stream and the client disconnects. The SDK’sdebug output goes to stderr, never stdout, for exactly this reason. If you add logging of your own to a stdio server, send it to stderr too.
What one session means here
One process is one session. The session id is generated when the firstwatch() runs and is shared for the life of the process, so every call the client makes lands in the same session.
That is what makes retries and cost per session meaningful: both are questions about a conversation, and a conversation split across many session ids answers neither.
Exit
The buffer is flushed on process exit, best effort, with a one-second timeout. A client that disconnects cleanly loses nothing; aSIGKILL loses whatever was still buffered, which is at most five seconds of calls.
Related
- Serving over HTTP — the other shape, and the one that is easy to get wrong
- Options