Test Coverage & Performance Improvements#222
Merged
Conversation
…/toolResult blocks Ensure WithTools option is applied last in CallWithTools (consistent with CallEx) so provider config options cannot accidentally overwrite restored tool definitions. Add integration test covering the exact issue #160 scenario: chain with toolUse/toolResult blocks but no explicit tools in the current turn. Fixes #160 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add comprehensive unit tests for GetBinaryVersion, IsDevelopMode, and GetBinaryName functions covering all code paths including default values, custom values, and combined version-revision formatting.
Add unit tests for IsMarkdownContent detection (headers, code blocks, bold, links, lists, plain text), InteractivePromptContext (input reading, whitespace trimming, context cancellation), GetYesNoInputContext (yes/no variants, case insensitivity), PrintJSON (valid/invalid data), and RenderMarkdown/PrintResult output functions.
Add unit tests for HttpError type (constructor, accessors, error interface), predefined error variables (HTTP codes, error codes for 12 categories), Success/Error response functions with gin test context including dev mode vs production mode behavior for error detail exposure.
Add unit tests for the embedding provider factory function covering all 7 supported providers (OpenAI, Ollama, Mistral, Jina, Huggingface, GoogleAI, VoyageAI), the none provider, unsupported provider error handling, custom URL/key/model configuration, and IsAvailable behavior.
Use io.Pipe() instead of strings.NewReader("") so the reader
genuinely blocks, forcing the select to take the ctx.Done() branch.
Assert require.ErrorIs(err, context.Canceled) instead of generic
assert.Error. Pipe writer is closed in defer to prevent goroutine
leaks.
Add context_test.go with 20 tests covering GetUserID, SetUserID, GetUserType, SetUserType, GetUserPermissions, SetUserPermissions, validateUserType, and validatePermission. Includes table-driven tests for validation functions and wrong-type assertion checks.
GetHTTPClient creates http.Client without a Timeout field, causing goroutines to hang indefinitely when an external API (LLM provider, search tool, etc.) stops responding. This affects all 17 call sites across every provider (OpenAI, Anthropic, Gemini, DeepSeek, Kimi, Qwen, GLM, Ollama, custom) and all search tools (Tavily, DuckDuckGo, Sploitus, Perplexity, Google, Traversaal, SearxNG). Changes: - Add HTTP_CLIENT_TIMEOUT env var (default: 600s / 10 minutes) - Set Timeout on all http.Client instances returned by GetHTTPClient - When cfg is nil, return a client with the default timeout instead of http.DefaultClient (which has no timeout) - Add 5 unit tests covering default, custom, zero, nil, and proxy timeout scenarios - Document the new env var in .env.example Relates to #176 (context canceled on agent delegation), which identified the missing HTTP client timeout as a contributing factor.
…dates Bumps the npm_and_yarn group with 2 updates in the /frontend directory: [dompurify](https://github.com/cure53/DOMPurify) and [immutable](https://github.com/immutable-js/immutable-js). Updates `dompurify` from 3.3.1 to 3.3.3 - [Release notes](https://github.com/cure53/DOMPurify/releases) - [Commits](cure53/DOMPurify@3.3.1...3.3.3) Updates `immutable` from 3.7.6 to 5.1.5 - [Release notes](https://github.com/immutable-js/immutable-js/releases) - [Changelog](https://github.com/immutable-js/immutable-js/blob/main/CHANGELOG.md) - [Commits](immutable-js/immutable-js@3.7.6...v5.1.5) --- updated-dependencies: - dependency-name: dompurify dependency-version: 3.3.3 dependency-type: indirect dependency-group: npm_and_yarn - dependency-name: immutable dependency-version: 5.1.5 dependency-type: indirect dependency-group: npm_and_yarn ... Signed-off-by: dependabot[bot] <support@github.com>
Add context_test.go with 15 tests covering GetInt64, GetUint64, GetString, GetStringArray, and GetStringFromSession. Each function has table-driven subtests for found, missing, and wrong-type cases. Session tests use gin-contrib/sessions/cookie with httptest.
Bumps the go_modules group with 3 updates in the /backend directory: [go.opentelemetry.io/otel/sdk](https://github.com/open-telemetry/opentelemetry-go), [golang.org/x/crypto](https://github.com/golang/crypto) and [google.golang.org/grpc](https://github.com/grpc/grpc-go). Updates `go.opentelemetry.io/otel/sdk` from 1.36.0 to 1.40.0 - [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-go@v1.36.0...v1.40.0) Updates `golang.org/x/crypto` from 0.44.0 to 0.45.0 - [Commits](golang/crypto@v0.44.0...v0.45.0) Updates `google.golang.org/grpc` from 1.73.0 to 1.79.3 - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](grpc/grpc-go@v1.73.0...v1.79.3) --- updated-dependencies: - dependency-name: go.opentelemetry.io/otel/sdk dependency-version: 1.40.0 dependency-type: direct:production dependency-group: go_modules - dependency-name: golang.org/x/crypto dependency-version: 0.45.0 dependency-type: direct:production dependency-group: go_modules - dependency-name: google.golang.org/grpc dependency-version: 1.79.3 dependency-type: direct:production dependency-group: go_modules ... Signed-off-by: dependabot[bot] <support@github.com>
Add comprehensive unit tests for NewConfig defaults, environment variable overrides, URL parsing, provider server URL defaults, summarizer defaults, search engine defaults, and ensureInstallationID logic including UUID generation, file persistence, and invalid value handling.
Add clearConfigEnv helper that clears all Config struct env vars via t.Setenv, and use t.Chdir(t.TempDir()) to isolate filesystem side effects from godotenv.Load() and ensureInstallationID(). Tests now pass regardless of environment variables set in the calling shell.
Signed-off-by: Dmitry Ng <19asdek91@gmail.com>
fix(bedrock): always include toolConfig when messages contain toolUse/toolResult blocks
test: add unit tests for pkg/version package
test: add unit tests for pkg/config package
test: add unit tests for pkg/terminal package
test: add unit tests for pkg/server/response package
test: add unit tests for pkg/providers/embeddings package
test: add unit tests for pkg/graph context helpers
test: add unit tests for pkg/server/context helpers
…go_modules-a62524d0e0 chore(deps): bump the go_modules group across 1 directory with 3 updates
…nd/npm_and_yarn-fa6563b207 chore(deps): bump the npm_and_yarn group across 1 directory with 2 updates
fix(system): add configurable timeout to HTTP client
- Updated relevant files including `.env.example`, `docker-compose.yml`, and documentation to reflect this new setting. - Enhanced server settings and locale files to support the new timeout configuration. - Adjusted HTTP client initialization to utilize the configured timeout value.
…tarting - Modified prompt templates to enforce completion requirements for function calls.
…x not working - Introduced tests for HTTP client timeout configuration, validating default, custom, and zero timeout scenarios. - Added tests for agent supervision settings, ensuring correct defaults and overrides based on environment variables. - Enhanced existing tests for context and response handling to improve coverage and reliability.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the Change
Problem
PentAGI codebase had several quality and performance issues requiring attention:
Test Coverage Gaps:
HTTP Client Timeout Missing:
Tool Call ID Detection Inefficiency:
AWS Bedrock Compatibility:
Solution
Comprehensive Test Coverage:
HTTP Client Timeout Configuration:
HTTP_CLIENT_TIMEOUTenvironment variable (default: 600 seconds)Tool Call ID Template Optimization:
testTemplate()fast-path validationBedrock toolConfig Fix:
Dependency Updates:
Closes #160
Type of Change
Areas Affected
Testing and Verification
Test Configuration
Test Steps
cd backend && go test ./...Test Results
go fmt,go vet,golangci-lintcleannpm run lintpassedSecurity Considerations
No Security Impact:
Performance Impact
Improvements:
Token Savings:
Documentation Updates
Deployment Notes
New Environment Variable (Optional):
# HTTP client timeout for external APIs (default: 600 seconds, 0 = unlimited) HTTP_CLIENT_TIMEOUT=600Configuration Notes:
.envfile or installer wizardCompatibility:
Deployment Steps:
.envif custom timeout neededdocker compose build(dependency updates)docker compose up -dChecklist
Code Quality
go fmtandgo vet(for Go code)npm run lint(for TypeScript/JavaScript code)Security
Compatibility
Documentation
Additional Notes
Key Changes by Category
Test Coverage Improvements
Added 200+ Unit Tests (PRs #198, #199, #200, #201, #202, #213, #214):
pkg/version- Binary version, develop mode detection, binary namepkg/config- Configuration loading, defaults, env overrides, Installation ID handlingpkg/terminal- Markdown detection, interactive prompts, context cancellation, JSON/markdown outputpkg/server/response- HttpError type, 78 predefined errors, dev/production mode response handlingpkg/providers/embeddings- All 7 providers (OpenAI, Ollama, Mistral, Jina, Huggingface, GoogleAI, VoyageAI)pkg/graph/context- User ID/type/permissions helpers, validation functions, admin regexpkg/server/context- Gin context helpers (GetInt64, GetUint64, GetString, GetStringArray, GetStringFromSession)Test Quality Standards Applied:
Contributors: @mason5052
Performance Optimizations
Tool Call ID Template Fast-Path (Commit 55e0ac5):
backend/pkg/providers/provider/agents.gotestTemplate()function validates known templates with single LLM callHTTP Client Timeout (PR #205, Commit 47ae6fe):
backend/pkg/system/utils.go,backend/pkg/config/config.goHTTP_CLIENT_TIMEOUTenv var (default 600s, 0=unlimited)Bug Fixes
Bedrock toolConfig Requirement (PR #196):
backend/pkg/providers/bedrock/bedrock.gorestoreMissedToolsFromChain(),collectToolUsageFromChain(),inferSchemaFromArguments()Dependencies
Go Modules (PR #215, Commit 47ae6fe):
go.opentelemetry.io/otel/sdkv1.36.0 → v1.39.0 (rolled back from v1.40.0 for compatibility)golang.org/x/cryptov0.44.0 → v0.46.0google.golang.org/grpcv1.73.0 → v1.79.3Frontend Dependencies (PR #207):
dompurify3.3.1 → 3.3.3 (security patches)immutable3.7.6 → 5.1.5 (major version update)Contributors
This release includes contributions from:
Special thanks to community contributors for improving PentAGI's code quality!
Merged Pull Requests
Issues Addressed