Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 28, 2026

Related GitHub Issue

Closes: #11049

Description

This PR adds comprehensive diagnostic logging to NativeOllamaHandler to help debug cases where Ollama requests hang indefinitely.

Key changes:

  • Added logging in ensureClient() showing the base URL being used
  • Added request timing logs at key points in createMessage():
    • Request start timestamp
    • Model fetch timing and cache status
    • Chat request details (URL, model, message count, tool count)
    • Stream start timing
  • Added warning when a model is not found in the tool-capable models list (which could indicate the model does not support native tool calling)
  • Added DEFAULT_OLLAMA_TIMEOUT_MS constant (5 minutes) to document expected slow model loading times

Design choices:

  • Used console.log for info-level logging and console.warn for potential issues
  • Timing logs use Date.now() for millisecond precision
  • Warning about tool capability includes a suggested diagnostic command (ollama show <model>)

Test Procedure

  1. All existing tests pass (15/15 in native-ollama.spec.ts)
  2. ESLint passes with no warnings
  3. Type checking passes

To verify the logging:

  1. Configure Roo Code to use Ollama with a local model
  2. Open the VS Code Output panel (Developer Tools console)
  3. Send a message to trigger an Ollama request
  4. Observe the [Ollama] prefixed log messages showing request timing

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue
  • Scope: Changes are focused on adding diagnostic logging for Ollama
  • Self-Review: Code has been reviewed
  • Testing: Existing tests pass; logging changes are difficult to unit test
  • Documentation Impact: No user-facing documentation changes required
  • Contribution Guidelines: Read and agreed

Documentation Updates

  • No documentation updates are required.

Additional Notes

This PR complements PR #11055 which added diagnostic logging for model filtering. Together, these changes will help users identify:

  1. If requests are reaching Ollama at all
  2. Where in the request lifecycle things are hanging
  3. If models are being filtered due to missing tool capabilities

The root cause of issue #11049 may be related to Ollama models taking 30-60+ seconds to load into memory on first use. The added logging will help confirm this hypothesis.


Important

Add diagnostic logging to NativeOllamaHandler for debugging request hangs, including request timing and tool capability warnings.

  • Logging Enhancements:
    • Add logging in ensureClient() for base URL.
    • Add request timing logs in createMessage() for request start, model fetch, chat request details, and stream start.
    • Add warning in createMessage() for models not found in tool-capable list.
  • Constants:
    • Add DEFAULT_OLLAMA_TIMEOUT_MS (5 minutes) for slow model loading.
  • Misc:
    • Use console.log for info and console.warn for warnings.
    • Timing logs use Date.now() for precision.

This description was created by Ellipsis for 330c3d4. You can customize this summary. It will automatically update as commits are pushed.

Adds comprehensive logging to help diagnose cases where Ollama requests
hang indefinitely, as reported in #11049. The logging includes:

- Client creation with base URL
- Request start timestamps
- Model fetch timing and cache status
- Warning when model is not in tool-capable list
- Chat request details (URL, model, message count, tool count)
- Stream start timing

Also adds DEFAULT_OLLAMA_TIMEOUT_MS constant (5 minutes) to accommodate
slow model loading times (Ollama models can take 30-60+ seconds to load
into memory on first use).

This logging will help users identify:
1. If the request is reaching Ollama at all
2. Where in the request lifecycle things are hanging
3. If the model is being filtered due to missing tool capabilities

Fixes #11049
@roomote
Copy link
Contributor Author

roomote bot commented Jan 28, 2026

Rooviewer Clock   See task on Roo Cloud

Review completed with 2 minor issues found.

  • Unused DEFAULT_OLLAMA_TIMEOUT_MS constant (defined but never applied to client)
  • Unused modelInfo variable in destructuring

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Comment on lines +17 to +19
// Default timeout for Ollama requests (5 minutes to accommodate slow model loading)
// Ollama models can take 30-60+ seconds to load into memory on first use
const DEFAULT_OLLAMA_TIMEOUT_MS = 300_000 // 5 minutes
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEFAULT_OLLAMA_TIMEOUT_MS is defined but never used. The constant and its comments suggest timeout handling exists for slow model loading, but it's not passed to the Ollama client anywhere. Either remove this dead code or apply the timeout to the client configuration if that was the intent.

Fix it with Roo Code or mention @roomote and request a fix.

const { id: modelId } = await this.fetchModel()

console.log(`[Ollama] createMessage: Fetching model info...`)
const { id: modelId, info: modelInfo } = await this.fetchModel()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modelInfo is destructured here but never used in the method. Consider removing it to avoid the unused variable.

Suggested change
const { id: modelId, info: modelInfo } = await this.fetchModel()
const { id: modelId } = await this.fetchModel()

Fix it with Roo Code or mention @roomote and request a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

Local Ollama Models Not Responsive

1 participant