Skip to content

release v0.3.0: Chat zero-value safety and consistent constructors#33

Merged
x2d7 merged 7 commits intomainfrom
dev
Feb 22, 2026
Merged

release v0.3.0: Chat zero-value safety and consistent constructors#33
x2d7 merged 7 commits intomainfrom
dev

Conversation

@x2d7
Copy link
Owner

@x2d7 x2d7 commented Feb 22, 2026

Summary

Two related improvements to Chat initialization and API consistency.

Fix: Chat panics without Tools field (#30)

Chat{} without Tools caused a nil pointer panic on the first Session() call.
ensureDefaults() now initializes missing Messages and Tools lazily at the entry point — existing values are never overwritten.

Refactor: consistent constructors

NewTools() previously returned Tools by value, while NewMessages() returned *Messages — forcing callers to manually take &toolList. Both types contain a mutex internally, so returning by pointer is correct regardless. Now both constructors return a pointer.

// before
toolList := tools.NewTools()
c := chat.Chat{Tools: &toolList}

// after
c := chat.Chat{Tools: tools.NewTools()}

Closes #30

@x2d7 x2d7 merged commit bdf1bd1 into main Feb 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chat не работает без указания поля Tools

1 participant