* llms/openai: sanitize HTTP errors to prevent API key exposure (#1393)
Fix security issue where context deadline errors could expose API keys and
sensitive request details in error messages. Added sanitizeHTTPError function
to detect context timeouts and network errors, then return generic error
messages without exposing sensitive information.
Changes:
- Added sanitizeHTTPError() function to sanitize HTTP client errors
- Updated chat.go to use sanitizeHTTPError() for http.Do() errors
- Updated embeddings.go to use sanitizeHTTPError() for http.Do() errors
- Added comprehensive test cases to prevent regression
* agents: fix ChainCallOption silent failure (#1416)
Fix issue where ChainCallOption parameters were silently ignored by Executor.Call() and Agent implementations.
Changes:
- Updated Agent.Plan() interface signature to accept variadic ChainCallOption parameters
- Updated Executor.Call() to accept and propagate options to Agent.Plan()
- Updated Executor.doIteration() to propagate options through the chain
- Updated OneShotZeroAgent.Plan() to accept and pass options to chains.Predict()
- Updated ConversationalAgent.Plan() to accept and pass options to chains.Predict()
- Updated OpenAIFunctionsAgent.Plan() to accept and pass options to LLM.GenerateContent()
- Exported GetLLMCallOptions() function for option conversion (was getLLMCallOptions)
- Updated test mock to match new Agent interface signature
Now users can pass LLM configuration options (temperature, max tokens, etc.) through executors to agents.
test: improve test resilience with better HTTP recording handling
Add hasExistingRecording helper to detect available recordings and skip tests
gracefully when recordings are unavailable. Replace generic credential checks
with specific recording validation and provide clear error messages.
* build: add examples-updater tool and update examples to v0.1.14-pre.1
Add a new tool to automate updating langchaingo version references in example
projects and use it to update all examples to v0.1.14-pre.1. The tool also
removes temporary replace directives that are no longer needed.
- Add update-examples Makefile target that runs the new tool
- Create internal/devtools/examples-updater implementation
- Update all example go.mod files to reference v0.1.14-pre.1
- Remove replace directives in googleai and vertex examples
- Update dependencies in main go.mod/go.sum
* httprr: improve header normalization and test container setup
Add header normalization to make HTTP recordings more stable:
- Add normalizeGoogleAPIClientHeader and normalizeVersionHeader functions
- Normalize User-Agent, x-goog-api-client and other version headers
- Remove OpenAI-Project header for consistency
- Preserve body for both replay lookup and recording
- Add comprehensive tests for header normalization
Improve testcontainer environment detection:
- Better handling of non-standard Docker socket paths
- Disable Ryuk reaper by default for resource efficiency
- Add verbose logging option via environment variable
* httputil: add ApiKeyTransport for query parameter API keys
Add a reusable ApiKeyTransport that adds API keys to URL query parameters:
- Create ApiKeyTransport implementation in httputil package
- Add comprehensive tests for the new transport
- Refactor googleai_test.go to use the shared transport
- Update chains/llm_test.go to use ApiKeyTransport with proper key scrubbing
This improves how API keys are handled with client libraries that don't
properly set keys when using custom HTTP clients, particularly useful
with httprr for testing Google API integrations.
* openai: remove duplicate MaxTokens field assignment
Remove redundant assignment where both MaxTokens and MaxCompletionTokens
were being set to the same value. MaxCompletionTokens is the preferred
field name that reflects OpenAI's API changes, while MaxTokens was
previously kept for backward compatibility.
* vectorstores/maridadb: add test infrastructure for MariaDB vectorstore
Add TestMain function for MariaDB vectorstore tests that ensures the proper
test environment is set up using the testctr package. This enables consistent
test container setup and teardown for MariaDB integration tests.
* all: normalize all httprr recordings for consistency
Update test recordings across all packages to use normalized headers:
- Standardize User-Agent to 'langchaingo-httprr'
- Normalize version information in x-goog-api-client headers
- Remove OpenAI-Project headers for consistency
- Fix deprecated Anthropic completion API tests
- Update HuggingFace test recordings with valid responses
These changes make test recordings stable across dependency updates
and different environments, preventing test failures from version changes.
* devtools: add utility tool for normalizing httprr test recordings
Add a command-line tool that standardizes version information in httprr recordings:
- Normalizes x-goog-api-client headers to use placeholder versions
- Standardizes x-amz-user-agent headers for consistency
- Replaces Go version strings with generic placeholders
- Supports dry-run mode to preview changes without modifying files
- Includes verbose output option for detailed change reporting
This tool helps maintain consistent test recordings across different environments
and dependency versions, preventing test failures from version changes.
* llms/openai: update OpenAI embedding test to use text-embedding-3-small model
Update the embedding test to use the current text-embedding-3-small model:
- Change model from text-embedding-ada-002 to text-embedding-3-small
- Adjust dimensions parameter from 1234 to 256 to match model capabilities
- Update test recording with appropriate response data
This change ensures tests remain compatible with OpenAI's current embedding
models and prevents test failures from API version changes.
* all: add broad httprr coverage, update dependencies, organize go.mod file, bump to 1.23
update go version to 1.23
add lots of test coverage via httprr recordings
update dependencies and organize go.mod
add testutil/testctr which helps work around a testcontainers-go+colima bug
expand the huggingface implementation and tests
expand capabilities of the ollama package
* examples: update examples, clean up module declarations
- Fix and relax lint rules (for now)
- Clean up and fix module declarations
- Add .gitattributes to mark go.sum as binary
* ci: separate and enhance CI workflows
- Split example builds into dedicated workflow
- Add comprehensive test coverage reporting
- Improve CI structure with matrix testing
- Add race condition testing
- Add automated PR coverage comments
* test: improve test reliability and agent message handling
- Simplify MRKL agent test to use basic math calculation
- Update OpenAI functions agent to use ToolChatMessage
- Add proper environment checks for Zep integration tests
* agents: fix issue in tool call handling for openai function agent
It's not used and not implemented correctly for almost any model.
If this is deemed useful, it will be more correct to expose a model name
from the LLM (or cliena?) and then invoke a standalone function familiar
with non-openai models.
Re #482