Keep Go files cohesive by responsibility, and make branching/conversion logic easy to extend.
1) Put types where they belong
GetExtraParams helpers) into types.go.embedding.go) for converter/transform functions only.2) Keep conversion logic readable
guard + switch over repeated inline if x.Type == ... checks.Example pattern:
if chunk.Index == nil || chunk.ContentBlock == nil {
return nil, nil, false
}
switch chunk.ContentBlock.Type {
case AnthropicContentBlockTypeToolUse:
// structured handling
case AnthropicContentBlockTypeRedactedThinking:
// structured handling
default:
return nil, nil, false
}
3) DRY repeated utilities safely
4) Centralize “magic” values
schemas (or a shared constants module) and reuse them across paths.5) Prefer strong typing / reuse helpers
map[string]any when the project has a structured type (e.g., schemas.OrderedMap).This reduces churn when adding new providers/types, makes reviews faster, and prevents subtle behavior drift from copy/pasted logic.