BoundaryML/baml · error
failed to get calls count: %w
Error message
failed to get calls count: %w
What it means
CallsCount() fetches the number of LLM calls recorded in a function log by invoking the remote 'calls_count' method through raw_objects.CallMethod. This error wraps any failure of that bridge call (transport, marshaling, method-not-found, runtime error). It is the wrapping variant, not the type-check variant.
Source
Thrown at engine/language_client_go/pkg/rawobjects_function_log.go:114
func (f *functionLog) RawLLMResponse() (string, error) {
result, err := raw_objects.CallMethod(f, "raw_llm_response", nil)
if err != nil {
return "", fmt.Errorf("failed to get raw LLM response: %w", err)
}
response, ok := result.(string)
if !ok {
return "", fmt.Errorf("unexpected type for raw LLM response: %T", result)
}
return response, nil
}
func (f *functionLog) CallsCount() (int, error) {
result, err := raw_objects.CallMethod(f, "calls_count", nil)
if err != nil {
return 0, fmt.Errorf("failed to get calls count: %w", err)
}
count, ok := result.(int)
if !ok {
return 0, fmt.Errorf("unexpected type for calls count: %T", result)
}
return count, nil
}
func (f *functionLog) Calls() ([]LLMCall, error) {
result, err := raw_objects.CallMethod(f, "calls", nil)
if err != nil {
return nil, fmt.Errorf("failed to get calls: %w", err)
}
result_cast := result.([]raw_objects.RawPointer)
calls := make([]LLMCall, len(result_cast))View on GitHub (pinned to bd85ce9dee)
Solutions
- Log the wrapped error (%w chain) to find the root cause from the bridge
- Verify the runtime object still exposes a 'calls_count' method (check runtime version vs Go bindings)
- Re-acquire the function log object instead of reusing a possibly-disposed one
Defensive patterns
Strategy: try-catch
Validate before calling
// no pre-call check possible; ensure the FunctionLog handle is fresh:
if flog == nil { return 0, errors.New("nil function log") } Try / catch
count, err := flog.CallsCount()
if err != nil {
return 0, fmt.Errorf("calls count unavailable: %w", err)
} Prevention
- Do not cache FunctionLog handles across runtime restarts
- Verify runtime version compatibility with the Go bindings
- Check runtime process health before querying many logs
When it happens
Trigger: Calling FunctionLog.CallsCount() when the underlying runtime object is stale/disposed, the 'calls_count' method is missing or renamed, or the runtime raises an exception while computing the count.
Common situations: Version mismatch where the runtime no longer exposes 'calls_count'; accessing a function log after its backing object was garbage-collected in the runtime; network/IPC transport failures to the language runtime.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- failed to get calls: %w
- failed to get selected call: %w
- failed to get tags: %w
- unexpected type for raw LLM response: %T
- failed to get text: %w
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/a00ad41b3ea3ddbc.
Report an issue: GitHub.