Skip to content

fix(agent): enable streaming for OpenAI-compatible gateways that require it - #1502

Open
MarsDoge wants to merge 3 commits into
NoFxAiOS:devfrom
MarsDoge:feat/mcp-force-stream
Open

MarsDoge wants to merge 3 commits into
NoFxAiOS:devfrom
MarsDoge:feat/mcp-force-stream

Conversation

@MarsDoge

@MarsDoge MarsDoge commented May 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add configurable MCP stream response behavior for OpenAI-compatible gateways.
  • Enable streaming in agent model calls and Telegram OpenAI custom-gateway clients when gateways require streamed responses.
  • Harden forced-stream handling: parse streamed content/reasoning/tool calls directly, stop on finish_reason when gateways omit data:[DONE], reset an idle timeout while stream lines arrive, and retry HTTP 504 gateway timeouts.

Tests

  • go test ./...
  • go vet ./...
  • gofmt/diff check on touched Go files

Notes

  • Updated this PR only with backend stream/retry/Telegram fixes.
  • Local unrelated dirty changes in api/handler_ai_model.go and web trader UI files were intentionally excluded.

@cla-assistant

cla-assistant Bot commented May 16, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@cla-assistant

cla-assistant Bot commented May 16, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions

Copy link
Copy Markdown

🤖 Advisory Check Results

These are advisory checks to help improve code quality. They won't block your PR from being merged.

📋 PR Information

Title Format: ✅ Good - Follows Conventional Commits
PR Size: 🟡 Medium (356 lines: +322 -34)

🔧 Backend Checks

Go Formatting: ⚠️ Needs formatting

Files needing formatting
agent/execution_state.go
agent/model_provider_catalog.go
agent/skill_dag_runtime.go
agent/stock.go
api/errors.go
api/handler_trader.go
api/handler_wallet.go
api/utils_test.go
config/config.go
kernel/engine.go

Go Vet: ✅ Good
Tests: ✅ Passed

Fix locally:

go fmt ./...      # Format code
go vet ./...      # Check for issues
go test ./...     # Run tests

⚛️ Frontend Checks

Build & Type Check: ✅ Success

Fix locally:

cd web
npm run build  # Test build (includes type checking)

📖 Resources

Questions? Feel free to ask in the comments! 🙏


These checks are advisory and won't block your PR from being merged. This comment is automatically generated from pr-checks-run.yml.

@MarsDoge
MarsDoge force-pushed the feat/mcp-force-stream branch from 9c7cdc4 to 83e2266 Compare May 16, 2026 09:08
@github-actions

Copy link
Copy Markdown

🤖 Advisory Check Results

These are advisory checks to help improve code quality. They won't block your PR from being merged.

📋 PR Information

Title Format: ✅ Good - Follows Conventional Commits
PR Size: 🟢 Small (202 lines: +201 -1)

🔧 Backend Checks

Go Formatting: ⚠️ Needs formatting

Files needing formatting
agent/execution_state.go
agent/model_provider_catalog.go
agent/skill_dag_runtime.go
agent/stock.go
api/errors.go
api/handler_trader.go
api/handler_wallet.go
api/utils_test.go
config/config.go
kernel/engine.go

Go Vet: ✅ Good
Tests: ✅ Passed

Fix locally:

go fmt ./...      # Format code
go vet ./...      # Check for issues
go test ./...     # Run tests

⚛️ Frontend Checks

Build & Type Check: ✅ Success

Fix locally:

cd web
npm run build  # Test build (includes type checking)

📖 Resources

Questions? Feel free to ask in the comments! 🙏


These checks are advisory and won't block your PR from being merged. This comment is automatically generated from pr-checks-run.yml.

@MarsDoge MarsDoge changed the title feat(mcp): support configurable stream responses fix(agent): enable streaming for OpenAI-compatible gateways that require it May 17, 2026
@github-actions

Copy link
Copy Markdown

🤖 Advisory Check Results

These are advisory checks to help improve code quality. They won't block your PR from being merged.

📋 PR Information

Title Format: ✅ Good - Follows Conventional Commits
PR Size: 🟡 Medium (382 lines: +375 -7)

🔧 Backend Checks

Go Formatting: ⚠️ Needs formatting

Files needing formatting
agent/execution_state.go
agent/model_provider_catalog.go
agent/skill_dag_runtime.go
agent/stock.go
api/errors.go
api/handler_trader.go
api/handler_wallet.go
api/utils_test.go
config/config.go
kernel/engine.go

Go Vet: ✅ Good
Tests: ✅ Passed

Fix locally:

go fmt ./...      # Format code
go vet ./...      # Check for issues
go test ./...     # Run tests

⚛️ Frontend Checks

Build & Type Check: ✅ Success

Fix locally:

cd web
npm run build  # Test build (includes type checking)

📖 Resources

Questions? Feel free to ask in the comments! 🙏


These checks are advisory and won't block your PR from being merged. This comment is automatically generated from pr-checks-run.yml.

@MarsDoge

Copy link
Copy Markdown
Contributor Author

Updated with the deployed backend hotfixes only:

  • MCP: retry 504 Gateway Timeout responses.
  • MCP forced stream: parse streamed content/reasoning/tool calls directly, handle finish_reason without data:[DONE], and add idle stream timeout reset.
  • Telegram: force streaming only for OpenAI provider configs with custom API URLs.
  • Tests added for 504 retry, stream tool-call/finish_reason parsing, and Telegram custom OpenAI ForceStream selection.

Local verification: go test ./..., go vet ./..., gofmt/diff check on touched Go files.

Excluded unrelated local dirty changes: api/handler_ai_model.go, web trader UI files, local patch/cache artifacts.

@github-actions

Copy link
Copy Markdown

🤖 Advisory Check Results

These are advisory checks to help improve code quality. They won't block your PR from being merged.

📋 PR Information

Title Format: ✅ Good - Follows Conventional Commits
PR Size: 🟡 Medium (628 lines: +597 -31)

🔧 Backend Checks

Go Formatting: ⚠️ Needs formatting

Files needing formatting
agent/execution_state.go
agent/model_provider_catalog.go
agent/skill_dag_runtime.go
agent/stock.go
api/errors.go
api/handler_trader.go
api/handler_wallet.go
api/utils_test.go
config/config.go
kernel/engine.go

Go Vet: ✅ Good
Tests: ✅ Passed

Fix locally:

go fmt ./...      # Format code
go vet ./...      # Check for issues
go test ./...     # Run tests

⚛️ Frontend Checks

Build & Type Check: ✅ Success

Fix locally:

cd web
npm run build  # Test build (includes type checking)

📖 Resources

Questions? Feel free to ask in the comments! 🙏


These checks are advisory and won't block your PR from being merged. This comment is automatically generated from pr-checks-run.yml.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant