Skip to content

Context ​

Files, URLs, memory.


Purpose ​

Provide AI with context — file attachments, URL references, conversation history chips.

<context> keeps supporting material visible and machine-readable instead of forcing attachments and memory into plain text descriptions.


G-Lang ​

grain
<context type="file" id="doc-123" name="spec.pdf" size="1024000" />
<context type="url" id="url-456" name="Wikipedia" preview="Free encyclopedia..." />
<context type="memory_chip" id="mem-789">User is building an AI library</context>

Attributes ​

AttributeTypeDescription
typefile | url | memory | memory_chip | conversationContext type
idstringUnique identifier
namestringDisplay name
previewstringPreview text/thumbnail
sizenumberFile size (bytes)
mimeTypestringMIME type
removabletrue | falseAllow removal

States ​

ATTACHED → LOADING → READY
    ↓         ↓
  REMOVING   ERROR

Events ​

EventDescription
context.attachContext added
context.loadLoading started
context.readyReady for AI
context.removeUser removed

Usage Notes ​

  • Use type to distinguish durable files from softer references such as URLs or memory chips.
  • Keep id stable when the same context object may be revisited across updates.
  • Pair <context> with <artifact> when the referenced object becomes something the user should inspect directly.

Released under the MIT License.