Skip to content
3 min read · 551 words

Class: Thought

Defined in: src/lib/classes/thought.ts:158

An immutable, validated internal reasoning trace produced by an agent.

Remarks

Represents an agent's internal thinking — distinct from @nhtio/adk!Message (which is part of the visible conversation) and never shown to end users directly. Carries an identity so reasoning traces can be attributed to a specific agent in multi-agent conversations. Constructed from a RawThought via rawThoughtSchema. The content field is always a @nhtio/adk!Tokenizable so token cost can be estimated inline.

Constructors

Constructor

ts
new Thought(raw: RawThought): Thought;

Defined in: src/lib/classes/thought.ts:214

Parameters

ParameterTypeDescription
rawRawThoughtThe raw thought input validated against rawThoughtSchema.

Returns

Thought

Throws

@nhtio/adk!E_INVALID_INITIAL_THOUGHT_VALUE when raw does not satisfy the schema.

Properties

PropertyModifierTypeDefault valueDescriptionDefined in
contentreadonlyTokenizableundefinedThe reasoning content as a @nhtio/adk!Tokenizable for inline token estimation.src/lib/classes/thought.ts:184
createdAtreadonlyDateTimeundefinedWhen this thought was recorded.src/lib/classes/thought.ts:198
idreadonlystringundefinedStable unique identifier for this thought.src/lib/classes/thought.ts:182
identityreadonlyIdentityundefinedThe identity of the agent who produced this thought.src/lib/classes/thought.ts:186
payloadreadonlyunknownundefinedOptional vendor-opaque payload that round-trips back to a matching model wire. See RawThought.payload.src/lib/classes/thought.ts:191
replayCompatibilityreadonlystring | undefinedundefinedOptional wire-shape identifier describing which adapter can safely replay this thought. See RawThought.replayCompatibility.src/lib/classes/thought.ts:196
updatedAtreadonlyDateTimeundefinedWhen this thought was last modified.src/lib/classes/thought.ts:200
schemastaticObjectSchema<RawThought>rawThoughtSchemaValidator schema that accepts a RawThought object. Remarks Reusable fragment for any schema that needs to validate or nest a thought entry.src/lib/classes/thought.ts:165

Methods

[ENCODE_METHOD]()

ts
ENCODE_METHOD: unknown;

Defined in: src/lib/classes/thought.ts:287

Serialise this Thought into an @nhtio/encoder snapshot.

Returns

unknown

A RawThought-shaped snapshot.

Remarks

Emits a RawThought-shaped object; content is the live @nhtio/adk!Tokenizable, identity the live @nhtio/adk!Identity, and the temporal fields live Luxon DateTimes (the encoder recurses into each). The vendor-opaque payload is passed through as-is — if it holds a value the encoder cannot serialise, encode throws (standard encoder behaviour). Round-trips via Thought.[DECODE_METHOD], which re-validates through the constructor.


[DECODE_METHOD]()

ts
static DECODE_METHOD: Thought;

Defined in: src/lib/classes/thought.ts:305

Reconstruct a Thought from a Thought.[ENCODE_METHOD] snapshot.

Parameters

ParameterTypeDescription
dataunknownThe snapshot produced by Thought.[ENCODE_METHOD].

Returns

Thought

A fully-validated Thought.


isThought()

ts
static isThought(value: unknown): value is Thought;

Defined in: src/lib/classes/thought.ts:177

Returns true if value is a Thought instance.

Parameters

ParameterTypeDescription
valueunknownThe value to test.

Returns

value is Thought

true when value is a Thought instance.

Remarks

Uses @nhtio/adk!isInstanceOf for cross-realm safety — instanceof would fail for instances created in a different module copy or VM context.