
 [ AI AVALON Terminate ]
                          Copyright (c) 2022 Hidetoshi NAGAI
                          Copyright (c) 2022 Kyutech AI AVALON Team

Protocol Version Support: 0.8.0 and above

Description of Processing at the End of Play:

------------------------------------------------------
1. Server -> Client

(1) When the play session ends, the server sends an exit command message
    (In text format, this would be represented as "exit <status>") to the
    client.

(2) The server waits to receive a status message of "successfully received"
    from the client, or times out waiting for the status message, and then
    closes the communication channel.


------------------------------------------------------
2. Client -> Agent

(1) Upon receiving the exit command message, the client replies with a status
    message of "successfully received", then proceeds to perform termination
    procedures for the connected agent.

(2) The client sends the exit command message to the agent.

(3) The client waits to receive a status message of "successfully received"
    from the agent, or times out waiting for the status message.

(4) After closing the communication channel, the client sends a TERM signal
    to the agent's process.


------------------------------------------------------
3. Agent

Upon receiving the exit command message, the agent responds with a status
message of "successfully received" before terminating.

Regardless of whether a "successfully received" is sent back, to reduce
the likelihood of the process continuing unnecessarily, the agent's process
receives a TERM signal.

Normally, the process should terminate upon receiving the TERM signal,
even without sending a status message of "successfully received", but it
is preferable to follow the formal procedure for termination rather than
relying on a forced termination via a signal.

Conversely, by trapping the TERM signal regardless of the acknowledgment
of a successful reception, the agent's process can avoid termination.
This allows for time-consuming processes such as logging playtime or
outputting internal states to be completed before the agent's process
terminates.


-----------------------------------------------------------------------------
end of document
-----------------------------------------------------------------------------
