Skip to content

feat: tool cost system and PPTX image handling fixes#193

Merged
Mile-Away merged 3 commits intotestfrom
feature/ppt-generate
Jan 22, 2026
Merged

feat: tool cost system and PPTX image handling fixes#193
Mile-Away merged 3 commits intotestfrom
feature/ppt-generate

Conversation

@xinquiry
Copy link
Collaborator

Summary

  • Implement per-tool cost configuration system replacing flat file generation cost
  • Fix PPTX image handling: prefer resolved URL over image_id
  • Fix tool result JSON parsing for cost calculation
  • Add security check for image_id ownership verification

Changes

  • Add ToolCostConfig to registry for configurable per-tool costs
  • Add raw_result field to tool response events for accurate cost calculation
  • Fix ImageFetcher to prefer URL when both URL and image_id are present
  • Add user_id ownership verification for image_id resolution

Test plan

  • Unit tests for calculate_tool_cost pass
  • Unit tests for ConsumptionCalculator pass
  • Pyright type checking passes
  • Manual testing with tool calls

🤖 Generated with Claude Code

xinquiry and others added 3 commits January 22, 2026 10:53
- Add image_slides mode for PPTX with full-bleed AI-generated images
- Add ImageBlock.image_id field for referencing generated images
- Add ImageSlideSpec for image-only slides
- Add ImageFetcher service for fetching images from various sources
- Reorganize knowledge module from single file to module structure
- Move document utilities from app/mcp/ to app/tools/utils/documents/
- Resolve image_ids to storage URLs in async layer (operations.py)
- Fix type errors and move tests to proper location

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Sorry @xinquiry, your pull request is larger than the review limit of 150000 diff characters

@Mile-Away Mile-Away merged commit 1c4d901 into test Jan 22, 2026
2 checks passed
@Mile-Away Mile-Away deleted the feature/ppt-generate branch January 22, 2026 10:29
Mile-Away added a commit that referenced this pull request Jan 22, 2026
* Feature/literature mcp (#192)

* feat: literature-MCP 完整功能

* refactor: improve boolean parsing and logging in literature search functions

* feat: enhance literature search functionality with improved query validation and detailed results formatting

* refactor: rename oa_url to access_url in LiteratureWork model and related tests

* feat: remove test-build workflow and update README for development setup

* feat: tool cost system and PPTX image handling fixes (#193)

* fix: prompt, factory

* feat: enhanced ppt generation with image slides mode

- Add image_slides mode for PPTX with full-bleed AI-generated images
- Add ImageBlock.image_id field for referencing generated images
- Add ImageSlideSpec for image-only slides
- Add ImageFetcher service for fetching images from various sources
- Reorganize knowledge module from single file to module structure
- Move document utilities from app/mcp/ to app/tools/utils/documents/
- Resolve image_ids to storage URLs in async layer (operations.py)
- Fix type errors and move tests to proper location

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: implement the tool cost

---------

Co-authored-by: Claude <noreply@anthropic.com>

* fix: fix the first time calling knowledge tool error (#194)

* fix: fix the wrong cache for second call of agent tools (#195)

* feat: several improvements (#196)

* fix: jump to latest topic when click agent

* feat: allow more than one image for generate image

* feat: allow user directly edit mcp in the chat-toolbar

* feat: improve the frontend perf

* feat: multiple UI improvements and fixes (#198)

* fix: jump to latest topic when click agent

* feat: allow more than one image for generate image

* feat: allow user directly edit mcp in the chat-toolbar

* feat: improve the frontend perf

* fix: restore previous active topic when clicking agent

Instead of always jumping to the latest topic, now tracks and restores
the previously active topic for each agent when switching between them.

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: add context menu to FocusedView agents and download button to lightbox

- Add right-click context menu (edit/delete) to compact AgentListItem variant
- Render context menu via portal to escape overflow:hidden containers
- Add edit/delete handlers to FocusedView with AgentSettingsModal and ConfirmationModal
- Add download button to image lightbox with smart filename detection

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: add web_fetch tool bundled with web_search

- Add web_fetch tool using Trafilatura for content extraction
- Bundle web_fetch with web_search in frontend toolConfig
- Group WEB_SEARCH_TOOLS for unified toggle behavior
- Only load web_fetch when web_search is available (SearXNG enabled)
- Update tool capabilities mapping for web_fetch

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>

---------

Co-authored-by: Meng Junxing <junxingmeng@gmail.com>
Co-authored-by: Harvey <q-query@outlook.com>
Co-authored-by: Claude <noreply@anthropic.com>
Mile-Away pushed a commit that referenced this pull request Jan 22, 2026
## [1.0.8](v1.0.7...v1.0.8) (2026-01-22)

### 🐛 Bug Fixes

* Literature MCP, tool cost system, and UI improvements ([#199](#199)) ([73b2c7d](73b2c7d)), closes [#192](#192) [#193](#193)
Mile-Away added a commit that referenced this pull request Jan 25, 2026
* Feature/literature mcp (#192)

* feat: literature-MCP 完整功能

* refactor: improve boolean parsing and logging in literature search functions

* feat: enhance literature search functionality with improved query validation and detailed results formatting

* refactor: rename oa_url to access_url in LiteratureWork model and related tests

* feat: remove test-build workflow and update README for development setup

* feat: tool cost system and PPTX image handling fixes (#193)

* fix: prompt, factory

* feat: enhanced ppt generation with image slides mode

- Add image_slides mode for PPTX with full-bleed AI-generated images
- Add ImageBlock.image_id field for referencing generated images
- Add ImageSlideSpec for image-only slides
- Add ImageFetcher service for fetching images from various sources
- Reorganize knowledge module from single file to module structure
- Move document utilities from app/mcp/ to app/tools/utils/documents/
- Resolve image_ids to storage URLs in async layer (operations.py)
- Fix type errors and move tests to proper location

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: implement the tool cost

---------

Co-authored-by: Claude <noreply@anthropic.com>

* fix: fix the first time calling knowledge tool error (#194)

* fix: fix the wrong cache for second call of agent tools (#195)

* feat: several improvements (#196)

* fix: jump to latest topic when click agent

* feat: allow more than one image for generate image

* feat: allow user directly edit mcp in the chat-toolbar

* feat: improve the frontend perf

* feat: multiple UI improvements and fixes (#198)

* fix: jump to latest topic when click agent

* feat: allow more than one image for generate image

* feat: allow user directly edit mcp in the chat-toolbar

* feat: improve the frontend perf

* fix: restore previous active topic when clicking agent

Instead of always jumping to the latest topic, now tracks and restores
the previously active topic for each agent when switching between them.

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: add context menu to FocusedView agents and download button to lightbox

- Add right-click context menu (edit/delete) to compact AgentListItem variant
- Render context menu via portal to escape overflow:hidden containers
- Add edit/delete handlers to FocusedView with AgentSettingsModal and ConfirmationModal
- Add download button to image lightbox with smart filename detection

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: add web_fetch tool bundled with web_search

- Add web_fetch tool using Trafilatura for content extraction
- Bundle web_fetch with web_search in frontend toolConfig
- Group WEB_SEARCH_TOOLS for unified toggle behavior
- Only load web_fetch when web_search is available (SearXNG enabled)
- Update tool capabilities mapping for web_fetch

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>

* feat: fix the fork issue and implement the locked fork

---------

Co-authored-by: Meng Junxing <junxingmeng@gmail.com>
Co-authored-by: Harvey <q-query@outlook.com>
Co-authored-by: Claude <noreply@anthropic.com>
Mile-Away added a commit that referenced this pull request Jan 26, 2026
* Feature/better agent community (#200)

* Feature/literature mcp (#192)

* feat: literature-MCP 完整功能

* refactor: improve boolean parsing and logging in literature search functions

* feat: enhance literature search functionality with improved query validation and detailed results formatting

* refactor: rename oa_url to access_url in LiteratureWork model and related tests

* feat: remove test-build workflow and update README for development setup

* feat: tool cost system and PPTX image handling fixes (#193)

* fix: prompt, factory

* feat: enhanced ppt generation with image slides mode

- Add image_slides mode for PPTX with full-bleed AI-generated images
- Add ImageBlock.image_id field for referencing generated images
- Add ImageSlideSpec for image-only slides
- Add ImageFetcher service for fetching images from various sources
- Reorganize knowledge module from single file to module structure
- Move document utilities from app/mcp/ to app/tools/utils/documents/
- Resolve image_ids to storage URLs in async layer (operations.py)
- Fix type errors and move tests to proper location

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: implement the tool cost

---------

Co-authored-by: Claude <noreply@anthropic.com>

* fix: fix the first time calling knowledge tool error (#194)

* fix: fix the wrong cache for second call of agent tools (#195)

* feat: several improvements (#196)

* fix: jump to latest topic when click agent

* feat: allow more than one image for generate image

* feat: allow user directly edit mcp in the chat-toolbar

* feat: improve the frontend perf

* feat: multiple UI improvements and fixes (#198)

* fix: jump to latest topic when click agent

* feat: allow more than one image for generate image

* feat: allow user directly edit mcp in the chat-toolbar

* feat: improve the frontend perf

* fix: restore previous active topic when clicking agent

Instead of always jumping to the latest topic, now tracks and restores
the previously active topic for each agent when switching between them.

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: add context menu to FocusedView agents and download button to lightbox

- Add right-click context menu (edit/delete) to compact AgentListItem variant
- Render context menu via portal to escape overflow:hidden containers
- Add edit/delete handlers to FocusedView with AgentSettingsModal and ConfirmationModal
- Add download button to image lightbox with smart filename detection

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: add web_fetch tool bundled with web_search

- Add web_fetch tool using Trafilatura for content extraction
- Bundle web_fetch with web_search in frontend toolConfig
- Group WEB_SEARCH_TOOLS for unified toggle behavior
- Only load web_fetch when web_search is available (SearXNG enabled)
- Update tool capabilities mapping for web_fetch

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>

* feat: fix the fork issue and implement the locked fork

---------

Co-authored-by: Meng Junxing <junxingmeng@gmail.com>
Co-authored-by: Harvey <q-query@outlook.com>
Co-authored-by: Claude <noreply@anthropic.com>

* fix: prevent forked agents from being republished to marketplace (#201)

* fix: prevent forked agents from being republished to marketplace

Forked agents were able to be republished, which could expose the original
agent's configuration. This fix adds validation at both API and UI levels:

- Backend: Add validation in publish endpoint to reject agents with
  original_source_id set (HTTP 400)
- Frontend: Hide publish button for forked agents in AgentSettingsModal
  and WorkflowEditor
- Types: Add original_source_id and source_version fields to Agent interface

Co-Authored-By: Claude <noreply@anthropic.com>

* refactor: address code review feedback for fork detection

- Extract `isForked` helper variable to avoid duplication
- Use explicit nullish check (`!= null`) to match backend `is not None` semantic
- Replace implicit empty div spacer with dynamic justify-* class in WorkflowEditor

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: add justfile for better command

* feat: improve AGENTS.md and fix backend fix

---------

Co-authored-by: Claude <noreply@anthropic.com>

---------

Co-authored-by: xinquiry(SII) <100398322+xinquiry@users.noreply.github.com>
Co-authored-by: Meng Junxing <junxingmeng@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Mile-Away pushed a commit that referenced this pull request Jan 26, 2026
## [1.0.9](v1.0.8...v1.0.9) (2026-01-26)

### 🐛 Bug Fixes

* fix fork problem and add lock mode ([#202](#202)) ([73342cb](73342cb)), closes [#200](#200) [#192](#192) [#193](#193)
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.

2 participants