Package com.tnsai.hooks.events
Record Class PostChat
java.lang.Object
java.lang.Record
com.tnsai.hooks.events.PostChat
- Record Components:
eventId- ULID-shaped correlation idtimestamp- when the event was constructed (post-response)context- surrounding hook contextuserMessage- the user's message that drove this response (post-PreChat modifications, if any)assistantResponse- the final assistant text — Modify-ableelapsed- wall-clock from PreChat to PostChat
- All Implemented Interfaces:
ChatHookEvent,HookEvent
public record PostChat(String eventId, Instant timestamp, HookContext context, String userMessage, String assistantResponse, Duration elapsed)
extends Record
implements ChatHookEvent
Fires after the final assistant response for a user turn is ready
(issue #60). Typical use: content-safety scan on the response,
quality-metric collection, auto-tagging for downstream indexing.
Note on token usage: a detailed breakdown
(TokenUsage(prompt, completion, cached, reasoning, total))
lives in tnsai-llm's LLMCallLog — outside this
module's dep graph. Chat-level token totals are intentionally NOT
carried here; consumers that need per-call accounting use
ActionHookEvent hooks paired with
the LLMCallLog stream from #79.
- Since:
- 0.5.0 (issue #60)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theassistantResponserecord component.context()Returns the value of thecontextrecord component.elapsed()Returns the value of theelapsedrecord component.final booleanIndicates whether some other object is "equal to" this one.eventId()Returns the value of theeventIdrecord component.Short stable string identifier of the event kind, e.g.final inthashCode()Returns a hash code value for this object.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.Returns the value of theuserMessagerecord component.withAssistantResponse(String newResponse) Build a copy withnewResponsereplacingassistantResponse.
-
Constructor Details
-
PostChat
public PostChat(String eventId, Instant timestamp, HookContext context, String userMessage, String assistantResponse, Duration elapsed) Creates an instance of aPostChatrecord class.- Parameters:
eventId- the value for theeventIdrecord componenttimestamp- the value for thetimestamprecord componentcontext- the value for thecontextrecord componentuserMessage- the value for theuserMessagerecord componentassistantResponse- the value for theassistantResponserecord componentelapsed- the value for theelapsedrecord component
-
-
Method Details
-
eventType
Description copied from interface:HookEventShort stable string identifier of the event kind, e.g."PreToolUse". Default implementation derives it from the concrete record's simple class name; concrete records may override if a different naming is desirable. -
withAssistantResponse
Build a copy withnewResponsereplacingassistantResponse. Used by Modify hooks scrubbing the response (PII leak detection, compliance rewrites). -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
eventId
Returns the value of theeventIdrecord component. -
timestamp
Returns the value of thetimestamprecord component. -
context
Returns the value of thecontextrecord component. -
userMessage
Returns the value of theuserMessagerecord component.- Returns:
- the value of the
userMessagerecord component
-
assistantResponse
Returns the value of theassistantResponserecord component.- Returns:
- the value of the
assistantResponserecord component
-
elapsed
Returns the value of theelapsedrecord component.- Returns:
- the value of the
elapsedrecord component
-