Skip to content

🐛 Bugfix: import and export agent with skills - #3519

Closed
wjn1584 wants to merge 22 commits into
develop_qsj_export0725from
develop
Closed

🐛 Bugfix: import and export agent with skills#3519
wjn1584 wants to merge 22 commits into
develop_qsj_export0725from
develop

Conversation

@wjn1584

@wjn1584 wjn1584 commented Jul 28, 2026

Copy link
Copy Markdown
Member

No description provided.

MoeexT and others added 20 commits July 25, 2026 16:58
* Bugfix: 确保返回到agent-landing页面时,先创建并切换到一个新的 assistant-ui 线程,再设置 Agent

* Feat: add subagent call style & planning to do list

* fix ut

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* fix ut

* add ut

* fix ut

* add ut

* add ut

* add ut

* add ut

* add ut

* fix:  并行执行两个工具或子代理时,嵌套深度会互相污染的问题

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Configure default super admin password for offline deployments

* Document offline deployment package building and installation

* Add offline deployment config reuse and env template merging

* Document administrator password retrieval in installation guides

---------

Co-authored-by: hhhhsc <name>
…ws (#3495)

* ✨ Feat: Extend in-app notifications to MCP and skill repository reviews

Notify publishers and reviewers on submit/approve/reject for MCP and skill
listings, with listing/review content, navbar deep-links into mcp/skill space,
and shared apply/review modals aligned with agent repository.

* ✨ Feat: Extend in-app notifications to MCP and skill repository reviews

Notify publishers and reviewers on submit/approve/reject for MCP and skill
listings, with listing/review content, navbar deep-links into mcp/skill space,
and shared apply/review modals aligned with agent repository.

* ✨ Feat: Extend in-app notifications to MCP and skill repository reviews

Notify publishers and reviewers on submit/approve/reject for MCP and skill
listings, with listing/review content, navbar deep-links into mcp/skill space,
and shared apply/review modals aligned with agent repository.

* ✨ Feat: Extend in-app notifications to MCP and skill repository reviews

Notify publishers and reviewers on submit/approve/reject for MCP and skill
listings, with listing/review content, navbar deep-links into mcp/skill space,
and shared apply/review modals aligned with agent repository.
* 🐛 Bugfix: remove northbound stream returning conversation_id

* 🐛 Bugfix: remove northbound stream returning conversation_id
…ce (#3498)

🐛 Bugfix: Northbound /chat/run use latest agent version instead of default draft
🐛 Bugfix: NL2Skill function cannot connect to ModelEngine models
* ✨ feat(context): Add fine-grained context management infrastructure (PR-0)

Add foundational context management module under sdk/nexent/core/agents/context/
to support W8/W12/W13 workstreams for progressive component reduction, history
projections, and unified context policy.

Core components:
- ContextItem: Fine-grained context unit with type, authority tier, and fidelity levels
- ContextItemHandler: Pluggable handler interface for scoring and reducing context items
- ItemHandlerRegistry: Registry mapping context item types to their handlers
- 10 built-in handlers (system_prompt, tool, skill, memory, knowledge_base, etc.)
- ContextProjector: Converts ContextComponent to ContextItem with proper authority/fidelity
- Policy models: SelectionDecision, MemoryDecision for traceable policy decisions
- ReductionResult: Immutable record of context reduction operations
- Reason codes: 11 standardized codes for decision traceability

Testing:
- 77 unit tests covering all data models, handlers, and registry
- All tests pass with 0.59s execution time

This is infrastructure-only (no existing code modified) and provides the foundation
for subsequent PRs implementing context projection, policy engines, and handlers.

* feat(context): integrate ContextItem projection into ContextManager (PR-1)

- Add use_context_items config field (default False for backward compatibility)
- Add context_items field to ContextEvidence for traceability
- Implement project_context_items() method in ContextManager
- Integrate projection logic into assemble_final_context()
- Store _source_component reference in metadata for semantic equivalence
- Use component.to_messages() to produce formatted text (not JSON dumps)
- Add 15 projection tests covering all 7 component types
- Add 3 ManagedContextRuntime integration tests
- Remove test __init__.py files to fix namespace collision

All 112 tests pass. Oracle verified complete and correct.

* feat(context): add DB history projection for ReAct process persistence (PR-2)

Implement W12 DB History Projection to persist and reconstruct ReAct
execution details from conversation history.

Database layer:
- Add 5 nullable columns: run_id, step_id, tool_call_id, event_time
  on conversation_message_t and conversation_message_unit_t
- Add indexes on run_id and tool_call_id for query performance
- Extend conversation_db.py with optional history projection params
- Add get_message_units_by_run() and get_max_run_id_for_conversation()

SDK layer:
- Create HistoryProjector with dependency injection for DB queries
- Support 3 projection modes: model_context, resume, chat
- Produce HISTORY_TURN, TOOL_CALL_RESULT, WORKING_MEMORY ContextItems
- Wire into ContextManager.use_context_items=True path via config

Service layer:
- Track run_id/step_id/tool_call_id/event_time in _stream_agent_chunks()
- Pass tracking fields through save_message/save_message_unit wrappers
- Compute run_id before message creation for proper persistence

Tests: 21 new tests, 114 total context tests passing, zero regressions.

* feat(context): close PR-2 acceptance gaps — production wiring + integration tests

Production wiring:
- Thread conversation_id through execution chain: agent_service →
  create_agent_run_info → AgentConfig → ManagedContextRuntime →
  assemble_final_context → HistoryProjector
- Inject HistoryProjector into ContextManagerConfig before
  get_or_create_context_manager() so both run-scoped and
  conversation-scoped ContextManager paths receive it
- use_context_items remains False by default (opt-in)

Integration tests (7 new, 28 total):
- TestChatProjectionCompleteness: unit type coverage, ordering,
  metadata, source_refs completeness
- TestEndToEndIntegration: component + history projection →
  FinalContext, graceful failure handling, conversation_id gating

121 context tests + 28 HistoryProjector tests passing, zero regressions.

* fix(context): resolve 3 activation blockers for use_context_items pipeline

Blocker 0: Call register_all() in ContextManager.__init__ so
ItemHandlerRegistry is populated before any projection occurs.

Blocker 1: Add to_messages() method to ContextItemHandler base class
with default implementation, plus type-specific overrides in
HistoryTurnHandler, ToolCallResultHandler, and WorkingMemoryHandler.

Blocker 2: Remove mock of ItemHandlerRegistry.get in integration test
so the end-to-end path exercises real handlers.

198 tests passing (121 context agent + 77 context module), zero regressions.

* fix(context): move register_all() to lazy initialization to avoid import regression

Move register_all() call from ContextManager.__init__ to lazy initialization
in project_context_items() to avoid breaking isolated test loading.

Changes:
- Remove register_all() from __init__ (line 301-302)
- Add _ensure_handlers_registered() helper with idempotency flag
- Call helper at start of project_context_items()
- Handlers now register only when actually needed

This fixes the 124-test regression caused by eager import in __init__
breaking test_agent_context/test_pure_functions.py isolated loading.

All 254 context tests now pass (121 context + 77 module + 56 agent_context).

* feat(context): add OpenTelemetry instrumentation to context module

Add comprehensive OTel tracing to provide visibility into the context
assembly pipeline:

- ManagedContextRuntime: trace prepare_step() and prepare_final_answer()
- ContextManager: trace assemble_final_context(), project_context_items(),
  compress_if_needed(), and _do_generate_summary() with nested LLM spans
- HistoryProjector: trace project() with nested DB query spans

All spans include relevant attributes (conversation_id, purpose, counts)
and span events for key milestones. Backward compatible - spans are
no-ops when monitoring is disabled.

Testing: All 254 existing tests pass, no syntax errors.

* fix(context): correct compress_if_needed span scope and improve project_items attributes

Critical fix:
- Move 'with self._lock:' block inside trace_operation context manager
- Ensures all compression work (including LLM calls) is properly traced
- Fixes broken parent-child span hierarchy for compression path

Minor improvements:
- Add component_count as span attribute to project_context_items
- Remove unused 'as span' from assemble_final_context

All 254 tests pass.

* fix(context): use ContextManager uncompressed baseline for save% metric

Previously _last_uncompressed_est was set from input_messages which are
already compressed by prepare_step, making est_raw_i always equal est_i
and save% structurally ~0%. Now pull the truly-uncompressed token count
from ContextManager.get_token_counts()['last_uncompressed'], recorded in
compress_if_needed from the raw memory before compression.

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

* chore: expose temp_scripts test harness for cross-machine sync

Add test scripts and fixtures used during context-manager refactor
development. Only .py and .md files are tracked; .out run artifacts
remain ignored via .git/info/exclude.

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

* chore: add .gitignore in temp_scripts to suppress .out/.log artifacts

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

* chore: allow common ops by default, keep rm/mv/git push as ask

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

* refactor: extract SummaryTaskStep and ManagedRunContext into summary_step.py

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

* refactor: extract pure budget/cache/fingerprint helpers into budget.py

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

* refactor: extract LLMSummary class into llm_summary.py

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

* refactor: extract StepRenderer and compress_history_offline into step_renderer.py

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

* refactor: extract PreviousCompressor into previous_compression.py

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

* refactor: extract CurrentCompressor into current_compression.py

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

* refactor: extract compression stats functions into stats_export.py

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

* refactor: extract ContextManager orchestrator into manager.py

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

* fix: correct relative import depth for utils.token_estimation

The token_estimation module lives at core/utils/, not agents/utils/.
From agent_context/ sub-package, three dots (...utils) are needed
instead of two (..utils).

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

* refactor: wire agent_context package with __init__.py re-exports and remove monolith

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

* refactor: update test loader for agent_context package structure

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

* refactor: update tests to use standalone functions from decomposed agent_context package

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

* fix: align extra compression tests with v2 compressor behavior

The v2 PreviousCompressor and CurrentCompressor do not fall through
from incremental to fresh when LLM returns None - they return
PreviousCompressResult/CurrentCompressResult(summary_text=None)
immediately. Updated tests P3, C4 to match this behavior.
Updated P4 and C6_asymmetry to patch _summarize_pairs with
PreviousCompressResult instead of raw tuples.

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

* fix: correct relative import depth for context_runtime.contracts

The context_runtime package lives at core/context_runtime/, not
agents/context_runtime/. From agent_context/ sub-package, three dots
(...context_runtime) are needed instead of two (..context_runtime).

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

* chore: untrack temp_scripts and settings.local before PR

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

* chore: restore .claude/settings.local.json to match upstream

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

* test: add coverage for stats_export, step_renderer, and budget modules

- New test_stats_export.py: 21 tests covering all pure functions (100%)
- New test_step_renderer.py: 24 tests covering truncation, rendering,
  compress_history_offline with mock LLM (49%→86%)
- Extended test_pure_functions.py: tests for _is_context_length_error,
  has_invoked_tools, message_role, trim_pairs_to_budget (92%→97%)

Overall agent_context package coverage: 71% → 81%

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

* test: add llm_summary error-handling and output-format coverage (72%→100%)

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

* test: cover _step_stream uncompressed estimation path in core_agent

Adds two tests:
- test_step_stream_uses_context_manager_for_uncompressed_est: verifies
  _last_uncompressed_est is pulled from ContextManager.get_token_counts()
- test_step_stream_falls_back_without_context_manager: verifies fallback
  to msg_token_count when context_manager is None

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

* test: add fingerprint, change detection, and manager utility tests

Cover the largest untested blocks in manager.py:
- _normalize_for_fingerprint, _fingerprint
- _change_reasons, _stable_component_fingerprints
- _purpose_messages, _messages_from_memory
- _without_leading_stable_messages, _canonical_tools
- _estimate_tools_tokens, build_compressed_snapshot
- init keep_recent_steps cap, token estimation delegates

Manager.py coverage: 69% → 91%, overall: 82% → 92%

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

* chore: fix SonarCloud issues in test and llm_summary files

- test_pure_functions.py: use ValueError instead of generic Exception (S112)
- test_step_renderer.py: remove separator comments flagged as code (S125)
- llm_summary.py: use logger.exception() in except blocks (S8572)
- test_manager_fingerprint.py: replace unused variable with _ (S1481)

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

* fix(context): resolve strategy filtering bypass in use_context_items path

Critical bug fix: When use_context_items=True, assemble_final_context() was
passing ALL registered components to project_context_items() instead of only
strategy-selected components, causing token budget overflow and behavioral
divergence from use_context_items=False path.

Changes:
- Add selected_components field to ManagedRunContext to track filtered subset
- Modify prepare_run_context() to explicitly call strategy.select_components()
  and store both all components and selected components
- Fix assemble_final_context() to use run_context.selected_components
- Fix _stable_component_fingerprints to use filtered components
- Propagate selected_components through rebuilt ManagedRunContext

Additional improvements:
- Add OpenInference input/output value recording to all context module spans
- Fix trace_operation() to process input.value through payload preview
- Fix history_projector output scope to set on correct span

Verification:
- 5 new strategy filtering tests (all pass)
- 5 PR-0/1/2 comprehensive tests (all pass)
- 87 existing tests (all pass)
- Verified behavioral equivalence between use_context_items=True and False
- Verified OTel traces show correct input/output in Langfuse

Production ready: backward compatible, no breaking changes

* refactor: reduce duplication in step_renderer and fix Sonar warnings in compression and test files

- Extract _build_offline_user_prompt and _call_model_for_summary helpers from compress_history_offline
- Rename unused cache parameter to _cache with alias in current/previous compression (Sonar S1172)
- Replace unused idx variables with _ in test_cache_valid (Sonar S1481)
- Rename test methods to lowercase convention in test_compress_with_cache_extra (Sonar S100)

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

* chore: clean up root-level test files

Moved to test/sdk/core/agents/:
- test_pr0_1_2_comprehensive.py → test_context_pr0_1_2.py
- test_strategy_filtering_fix.py → test_strategy_filtering.py

Deleted (redundant or not suitable for CI):
- test_otel_smoke.py (manual smoke test, not a proper unit test)
- test_budget_equivalence.py (covered by test_strategy_filtering.py)
- test_assemble_equivalence.py (covered by test_strategy_filtering.py)
- test_agent_context_items.py (integration test requiring API keys)

* refactor: remove PR references from test names

- test_pr0_handlers -> test_handlers
- test_pr0_projector -> test_projector
- test_pr1_equivalence -> test_equivalence
- test_pr2_history_projector -> test_history_projector
- Updated all test output labels to remove PR-0/1/2 prefixes

* fix(tests): update test assertions to match new API signatures

- Add conversation_id parameter to create_agent_config and create_agent_run_info assertions
- Add run_id, step_id, tool_call_id, event_time parameters to create_message_unit assertions
- Update fake_save_message to accept **kwargs for additional parameters
- All tests now pass individually (177 + 327 + 68 = 572 tests)
- Note: test__stream_agent_chunks_captures_final_answer_and_adds_memory has a pre-existing issue with background task execution

* fix(tests): add missing ProcessType attributes to MockProcessType

The test was failing because MockProcessType was missing STEP_COUNT, TOOL,
and EXECUTION_LOGS attributes that are used in agent_service.py. This caused
an exception in the chunk processing loop that prevented captured_final_answer
from being set, which in turn prevented the background memory task from running.

Added the missing attributes to MockProcessType and added a small sleep to
ensure the background task has time to complete before assertions.

* fix: handle None history in agent request

Fixed TypeError when agent_request.history is explicitly None instead of absent.
Changed getattr(agent_request, 'history', []) to handle None case properly.

This bug prevented message persistence when is_debug=false, causing all event
log fields (run_id, step_id, tool_call_id, event_time) to remain NULL.

* test: add unit tests for conversation_db new functions and fix SonarCloud floating point comparison

- Add 5 tests for get_message_units_by_run (with/without run_id, empty result, string coercion, dict mapping)
- Add 4 tests for get_max_run_id_for_conversation (found, none, string coercion, zero edge case)
- Update stubs to include run_id and step_id attributes
- Fix floating point comparison in test_handlers.py using pytest.approx (SonarCloud S1244)

This improves patch coverage for conversation_db.py and fixes SonarCloud reliability rating.

* test: add SDK integration test with real model and LangFuse tracing

Add comprehensive integration test that verifies:
- Real LLM model execution through the SDK
- OpenTelemetry instrumentation captures spans correctly
- Context management with use_context_items=True works end-to-end
- LangFuse receives and displays traces properly

Test includes:
- test_context_items_with_real_model: Basic context management with real model
- test_context_compression_with_real_model: Compression with low token threshold
- test_history_projector_integration: History projection with real model

Requires OPENAI_API_KEY environment variable to run.

* test: fix SDK integration tests and mark as local_only

- Fix OpenAIModel initialization (add model_id parameter)
- Fix ActionStep initialization (use correct parameters)
- Fix HistoryProjector initialization (use query_units_fn)
- Fix ManagedContextRuntime.prepare_step call (remove conversation_id)
- Add local_only marker to pytest.ini
- Mark all SDK integration tests as local_only to skip in CI

These tests require OPENAI_API_KEY and network access, so they should
only run locally, not in CI environments.

* chore: remove temporary dev plan from git tracking

- Remove CONTEXT_MANAGEMENT_DEV_PLAN.md from git (keep locally)
- Add to .gitignore to prevent future commits

This is a temporary development document that should not be tracked in version control.

* docs: add spec coding workflow

* refactor: merge tool_call rows into JSON, remove run_id/event_time, remove WorkingMemoryHandler

- Merge tool+execution_logs into single tool_call row with JSON unit_content
- Remove run_id from conversation_message_t and conversation_message_unit_t
- Remove tool_call_id and event_time from conversation_message_unit_t
- Rename step_id to step_index for clarity
- Replace run_id grouping with message_id-based algorithm in HistoryProjector
- Remove WorkingMemoryHandler and WORKING_MEMORY context item type
- Remove resume projection from HistoryProjector
- Remove dead components field from ManagedRunContext
- Fix parameter ordering in create_agent_run_info()
- Add TOOL_CALL handling in frontend for both streaming and history
- Rewrite migration to be idempotent with proper DROP/ADD COLUMN
- Update all affected tests (backend + SDK)

* test: add tool_call merge tests and fix SonarCloud type mismatch

- Add 3 tests for tool_call merge logic in _stream_agent_chunks
- Fix string-to-int type mismatch in test_conversation_db.py

* chore: add spec-coding skill, update AGENTS.md and benchmark scripts

* chore: add .agents file and update .gitignore to exclude it

* Remove old doc

* ♻️ Clean up lagecy implementation of mem0 memory

* Merge origin/develop into dev/feature/memory_0709 (#3412)

Update feature branch with mainstream develop branch.

* 📃 Update spec-coding skills

* ✨ [WIP] Memory implementation Phase 1

* ✨ [WIP] Memory implementation Phase 2

* ✨ [WIP] Memory implementation Phase 4

* ✨ Memory settings and management frontend

* ✨ Memory settings and management frontend

* ✨ Support memory management and memory tool calling
🐛 Bugfix: add pdfinfo in data-process image to resovle files with images

* 🧪 Add test files

* 🧪 Add test files
♻️ Change memory seperate key

---------

Co-authored-by: Jinglong Wang <jasonwong2019@outlook.com>
Co-authored-by: liudongfei <744532452@qq.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: liudongfei <liudongfei4@huawei.com>
Co-authored-by: Jason Wang <56037774+JasonW404@users.noreply.github.com>
Co-authored-by: Nexent Agent <agent@nexent.local>
* ✨ Feature: some logo and description are customization

* ✨ Feature: some logo and description are customization

* ✨ Feature: some logo and description are customization

* ✨ Feature: some logo and description are customization

* ✨ Feature: some logo and description are customization

* ✨ Feature: some logo and description are customization

* ✨ Feature: some logo and description are customization

* ✨ Feature: some logo and description are customization

* ✨ Feature: some logo and description are customization

* ✨ Feature: some logo and description are customization

* ✨ Feature: some logo and description are customization

* ✨ Feature: some logo and description are customization

* Potential fix for pull request finding 'CodeQL / Information exposure through a stack trace'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

---------

Co-authored-by: hzw <hzw@qq.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…index, cache/filter consistency (#3494)

* 社区容器化MCP安装优化;
多租户市场隔离;
MCP列表缓存与过滤一致性;
本地镜像上传补充;

* fix

* fix

* 修复前端崩溃问题;
修复outer-apis不显示的问题

* 修复同名绕过问题

* fix test case
…word strength reset (#3485)

* 🐛Bugfix: fix incorrect model list when switching to video understanding models in batch add

* 🐛Bugfix: reset password strength indicator on re-entering register page (#3210)

* 🐛Bugfix: fix model deletion failure when API key becomes invalid (#2761)
* Refactor: Enforce all frontend API calls to via service layer

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…coped uniqueness (#3496)

* fix(skill-repository): refresh counts and optimize loading

* fix(skill): scope active skill name uniqueness by tenant

* fix(skill): restrict repository takedown menu to admins

* fix(skill): align repository review lifecycle

* test(skill): cover repository count branches

* fix(skill): preserve tab refresh after develop merge
…ly action history, and non-executable output rejection (#3493)

* fix: convert compressed JSON summary to Markdown before injecting into context

format_summary_output() was re-serializing parsed JSON back to JSON via
json.dumps, causing the compressed summary injected into conversation
context to be raw JSON. Models then mimicked JSON syntax in their final
answers.

Now the function converts JSON dicts to Markdown with section headings
(# Compact Result of History / ## Task Overview / ## Completed Work / etc.)
so the injected summary reads as natural language.

- String values render as paragraphs, list values as bullet items
- Unknown schema keys get title-cased headings
- Non-dict JSON and parse failures fall back to plain text
- All call sites (llm_summary, step_renderer, offline) benefit automatically
- Updated test to assert Markdown output

* fix: eliminate JSON intermediate format in context compression pipeline

The compression pipeline was doing a pointless JSON round-trip:
  Prompt asks JSON → LLM outputs JSON → format_summary_output() converts
  to Markdown → HistoryCompressor json.loads() back to dict → renderer
  converts back to text

This caused three problems:
1. HistoryCompressor silently degraded to mechanical truncation because
   json.loads() failed on Markdown output (regression from prior fix)
2. _render_summary() rendered dict summaries as flat 'key: value' lines
   without Markdown headings
3. _render_current_action() fallback dumped compact content as raw JSON,
   causing models to mimic JSON syntax in final answers

Changes:
- config.py: prompts now request Markdown with '# Compact Result of
  History' / '## Section' headings instead of JSON
- llm_summary.py: prompt builds Markdown section descriptions instead of
  json.dumps(schema); uses _strip_code_fences() instead of
  format_summary_output()
- history_compression.py: HistorySummaryCandidate.summary is now str;
  removed json.loads() gate; incremental compression passes previous
  summary as plain Markdown text
- rendering.py: _render_summary() handles legacy dict data via
  _summary_dict_to_markdown(); _render_current_action() renders compact
  actions as structured natural language instead of json.dumps()
- budget.py: simplified format_summary_output() to code-fence stripping
  only (JSON conversion removed)
- Tests updated to match new string-based summary and natural language
  action rendering

* fix: add Markdown heading quality gate for history compression

The old json.loads() gate served double duty as a quality filter —
unstructured LLM output was rejected and the compressor fell back to
mechanical truncation. After removing the JSON intermediate format,
any non-empty text was accepted as a valid summary.

Replace with a lightweight check: the summary must contain at least
one '##' section heading, ensuring the LLM produced structured
Markdown output. Plain text responses (e.g. 'lossy fallback') are
rejected and trigger the safe fallback path.

* feat: add unresolved_issues and next_steps to compression schema

Expand the default summary schema with two new sections to produce
more complete compressed context:

- unresolved_issues: problems, errors, or questions encountered but
  not yet resolved
- next_steps: concrete planned next actions and their expected
  outcomes

These complement the existing pending_items (blockers/waiting) and
key_decisions (resolved findings) by capturing open problems and
forward-looking plans that the agent needs to continue effectively
after compression.

Updated _SUMMARY_FIELD_HEADINGS and test mock to match.

* test: add coverage for legacy dict summary, tool_calls rendering, and _strip_code_fences

Cover previously uncovered paths to satisfy codecov/patch:
- _summary_dict_to_markdown: legacy dict-typed summary rendering
- _render_current_action: compact path with tool_calls (list and dict)
- _strip_code_fences: code fence stripping utility

* test: cover remaining rendering.py edge cases for codecov

- _summary_dict_to_markdown: list values, empty list, None, numeric, all-empty fallback
- _render_current_action: non-standard tool_calls (string), list with non-dict elements

* docs: explicitly list new schema fields in summary_system_prompt

Update the system prompt text to mention 'unresolved issues' and
'next steps' alongside the existing fields for consistency with the
expanded schema.

* fix: compact action history to read-only user role and reject non-executable outputs

- Replace Step/Called tool assistant format with read-only <completed_action_history> in user role
- Preserve string tool_calls.arguments (python_interpreter code no longer degrades to empty)
- Add InvalidActionFormatError for non-executable model outputs
- Non-executable outputs (Step N/Called tool, Markdown action record, action/tool_calls JSON,
  fenced action JSON, incomplete <code>/<RUN> protocol) now record as step error and continue
  loop instead of returning as final answer
- Natural language final answers remain compatible
- Add tests covering full degradation chain: invalid format -> parser error -> loop continues -> real answer

* test: add cases for preserving raw messages and handling invalid action outputs
* feat: File upload size can be configured(10-100MB)

* feat: File upload size can be configured(10-100MB)

---------

Co-authored-by: hzw <hzw@qq.com>
* Bugfix: Fix double scrollbar issue in agent selector

* 删除对init.sql的修改
…ures (#3508)

* Release/v2.2.1 (#3269)

* add_greeting_fields_to_agent-develop

* feat(knowledge-base): add preserve_source_file and post-index source cleanup

Let knowledge bases opt out of keeping uploaded MinIO copies after indexing
while retaining Elasticsearch chunks for retrieval. Default behavior remains
preserve_source_file=true for backward compatibility.

- Add preserve_source_file column (init.sql + v2.2.0_0601 migration)
- Accept preserve_source_file on create/update and northbound/vector APIs
- Support document DELETE scope=source_only and source_available in listings
- Run cleanup_source Celery task when preserve_source_file is false
- UI: create-KB toggle, list tag, knowledge-base preview when copy is missing
- Update vector-database SDK docs and backend tests

* test(data_process): stub knowledge_db, redis_service, and redis in test_worker

Align setup_mocks_for_worker with test_tasks so importing
backend.data_process.worker loads package __init__ without real DB/redis deps.

* test(data_process): shim cleanup_source for submit_process_forward_chain tests

* remove duplicate import

* fix: update unit tests for greeting_message and example_questions fields

* add init.sql to sonar.properites

* ♻️ Improvement: API to MCP conversion service supports configuring headers. (#3194)

* ♻️ Improvement: API to MCP conversion service supports configuring headers.
[Specification Details]
1. Front-end and back-end modifications

* ♻️ Improvement: API to MCP conversion service supports configuring headers.
[Specification Details]
1. Modify the frontend, after adding, set the HTTP headers to empty.
2. Modify test cases.

* ♻️ Improvement: Enhance processing of ES index names in memory banks. (#3196)

[Specification Details]
1. Replace all symbols in the index name that do not meet the rules with "_".
2. Modify test cases.

* feat: add active memory tools (StoreMemoryTool, SearchMemoryTool) (#3197)

- Implement StoreMemoryTool for explicit memory storage during agent reasoning
- Implement SearchMemoryTool for on-demand memory retrieval during conversations
- Integrate tools into agent creation flow (create_agent_info.py)
- Register tools in nexent_agent.py and tools/__init__.py
- Add MEMORY_OPERATION tool sign for proper categorization
- Fix memory_core.py cache key to include event loop ID (prevents cross-loop conflicts)
- Add comprehensive test coverage for both tools
- Add procedural memory verification documentation

Tools follow existing patterns: lazy imports, observer integration, error handling,
and respect user memory preferences (agent_share_option, disabled_agent_ids).

Co-authored-by: Dallas98 <40557804+Dallas98@users.noreply.github.com>

* 🐛 Bugfix: skill names and descriptions never load to context (#3205)

* 🐛 Bugfix: skill names and descriptions never load to context

* 🐛 Bugfix: skill names and descriptions never load to context

* 🐛 Bugfix: skill names and descriptions never load to context

* 🐛 Bugfix: official skills not copied to target directory

* 🐛 Bugfix: official skills not copied to target directory

* Feat: add selected count badges to tool/skill pool labels (#3206)

Co-authored-by: chase <byzhangxin11@126.com>

* 🐛 Bugfix: Fix attribution error when tool calling error (#3208)

* ✨ Feat: Add support for Word document generation, preview, and download (#3191)

* Feat: Add support for Word document generation, preview, and download

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Restrict uploads to a known safe workspace/output directory

* 修改单元测试

* 修复单元测试

* Bugfix: Store uploaded files in Minio for conversation messages to enable file visibility in history

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* ✨Feat:Enhance prompt optimization by integrating openjiuwen and fix related bugs (#3190)

* ✨Feat:add prompt optimization

* 🐛Bugfix: dockerbuild failed when running pipefail in python3_11

* 🔨Optimize: Optimize prompt optimization display page and interaction methods

* 🐛Bugfix: fix dependencies replication

* 🎨:Optimize frontend prompts and loading interface

* 🔧 Refactor: Update imports and remove redundant ENABLE_JIUWEN_SDK import in prompt_service.py

* 🔧 Refactor: Correct import path for NexentCapabilityError and enhance test coverage for prompt optimization service

* 🔧 Refactor: Update import paths for exception handling and improve logging formatting in prompt_service.py

* 🔧 Refactor: Simplify lazy imports in jiuwen_sdk_adapter.py and update import paths in prompt_service.py

* 🔧 Refactor: Enhance Jiuwen SDK adapter handling and improve test stubs in prompt_service.py and related test files

* 🧪test:Pydantic model for PromptTemplateRequest in test_prompt_template_app.py

* 🔧 Refactor: Remove unnecessary dependency exclusions from pyproject.toml

* 🔧 Update: Upgrade huggingface_hub dependency version in pyproject.toml

* 🔧 Update: Exclude unnecessary transitive dependencies and adjust huggingface_hub version in pyproject.toml

* 🔧 Test: Add mock modules for unstructured inference and set up package paths in test files

* 🔧 Test: Enhance test setup by adding optional SDK mocks and cleaning up module imports in data processing tests

* 🔧 Test: Consolidate mock module setup for unstructured inference across multiple test files

* 🔧 Test: Remove unused optional SDK mocks from test configuration

* 🔧 Refactor: Clean up imports and enhance dynamic loading of fastmcp components in Docker client

* 📦update:sdk dependence update

* Add CAS SSO integration and improve logout handling (#3072)

* feat: add CAS SSO integration

* Skip CAS logout when CAS_LOGOUT_URL is unset

* 取消转义

* Improve CAS logout handling and confirm user logout

* Disable account deletion for CAS users

* Add CAS session init SQL and k8s config

* clean code

* Remove agent guardrails design doc from tracking

* 补充文档

---------

Co-authored-by: hhhhsc <name>

* 🐛Bugfix: Remove unnecessary dependency exclusions and upgrade huggingface_hub version in pyproject.toml (#3211)

* refactor: move current time from system prompt to user message for prompt cache stability (#3203)

Remove {{time}} from all 4 prompt YAML templates (manager/managed × en/zh)
and strip time_str from the context_utils pipeline (_format_app_context,
build_skeleton_header_component, build_context_components,
build_app_context_string). Also remove time from create_agent_info render
kwargs and build_context_components call.

In CoreAgent.run, prepend [Current time: ...] to self.task so the timestamp
travels with the user message instead of being baked into the system prompt.
This makes the rendered system prompt fully deterministic per (agent_id,
tenant_id, version_no, language) — enabling prompt/KV cache hits across
requests for the same agent config.

Sync test_context_utils.py: drop time_str= from 3 test cases.

Remove unused datetime imports from context_utils.py and create_agent_info.py.

* 🐛 Bugfix: Fixed the issue of being unable to add MCP services via containerization. (#3213)

[Specification Details]
1. Modify the DEFAULT_NETWORK_NAME when starting the MCP service in the container to match the name in docker-compose.
2. Modify the parameters passed to the add_mcp_service method; custom_headers defaults to None.

* 🐛 Bugfix: Fixed the issue where uploaded text files could not be parsed during a session. (#3219)

* 🐛 Bugfix: Fixed the issue where uploaded text files could not be parsed during a session.
[Specification Details]
1. The return parameter of the file_process method has changed and needs to be unpacked.

* 🐛 Bugfix: Fixed the issue where uploaded text files could not be parsed during a session.
[Specification Details]
1. Modify test case.

* 🐛 Bugfix: Fixed an issue where the MCP service could not be added correctly after updating the FastMCP version. (#3222)

[Specification Details]
1. Add `kwargs` to the `create_httpx_client` function to accept all additional parameters.

* 🐛 Bugfix: Fix incomplete display of tenant resources page after window resize (#3215)

* Move non-shadcn ui component to other folder

* Bugfix: Fix incomplete display of tenant resources page after window resize

* Bugfix: Fix incomplete display of tenant resources page after window resize

* Add agent marketplace repository and version pinning for sub-agents (#3239)

* feat: add agent marketplace repository and pin sub-agent versions at publish

Introduce ag_agent_repository_t with list/status/publish/import APIs for
frozen agent snapshots. Pin selected_agent_version_no on agent relations when
publishing so sub-agents resolve to a fixed version at runtime. Extend agent
export/import to bundle skills in ZIP payloads and add embedding model fallback
when no model name is provided.

* feat: add agent marketplace repository and pin sub-agent versions at publish

Introduce ag_agent_repository_t with list/status/publish/import APIs for
frozen agent snapshots. Pin selected_agent_version_no on agent relations when
publishing so sub-agents resolve to a fixed version at runtime. Extend agent
export/import to bundle skills in ZIP payloads and add embedding model fallback
when no model name is provided.

* feat: add agent marketplace repository and pin sub-agent versions at publish

Introduce ag_agent_repository_t with list/status/publish/import APIs for
frozen agent snapshots. Pin selected_agent_version_no on agent relations when
publishing so sub-agents resolve to a fixed version at runtime. Extend agent
export/import to bundle skills in ZIP payloads and add embedding model fallback
when no model name is provided.

* feat: add agent marketplace repository and pin sub-agent versions at publish

Introduce ag_agent_repository_t with list/status/publish/import APIs for
frozen agent snapshots. Pin selected_agent_version_no on agent relations when
publishing so sub-agents resolve to a fixed version at runtime. Extend agent
export/import to bundle skills in ZIP payloads and add embedding model fallback
when no model name is provided.

* feat(agent): add verification configuration for agents and update related components (#3174)

* feat(agent): add verification configuration for agents and update related components

* feat(model): update model type labels and add monitoring dashboard translations

* 🐛 Bugfix: Fix inability to select agent from agent space to edit (#3240)

* Move non-shadcn ui component to other folder

* Bugfix: Fix incomplete display of tenant resources page after window resize

* Bugfix: Fix incomplete display of tenant resources page after window resize

* Bugfix: Fix inability to select agent from agent space to edit

* Bugfix: Display correct version info when viewing agent details

* Update data agent and ME CAS integration documentation (#3242)

* 补充dataagent对接文档

* 补充ME cas对接文档

* 补充ME cas对接文档

---------

Co-authored-by: hhhhsc <name>

* ✨ Add several northbound apis (#3223)

* ✨ Add several northbound apis

* ✨ Add several northbound apis

* ✨ Add several northbound apis

* ✨ Add several northbound apis

* ✨ Add several northbound apis

* refactor: simplify deployment script by removing unused variables and functions (#3245)

* feat(agent): add verification configuration for agents and update related components

* feat(model): update model type labels and add monitoring dashboard translations

* refactor(build_offline_package): simplify deployment script by removing unused variables and functions

* 🐛 Bugfix: Adjust agent detail UI layout to accommodate newly added "self-verification" field (#3246)

* Move non-shadcn ui component to other folder

* Bugfix: Fix incomplete display of tenant resources page after window resize

* Bugfix: Fix incomplete display of tenant resources page after window resize

* Bugfix: Fix inability to select agent from agent space to edit

* Bugfix: Display correct version info when viewing agent details

* Bugfix: Adjust agent detail UI layout to accommodate newly added "self-verification" field

* 补充sql (#3248)

* 补充sql

* 扩大limit限制

* 🐛 Bugfix: Fixed an issue where the MCP service failed to start in a Kubernetes container. (#3254)

[Specification Details]
1. Modify the pod naming logic to convert all non-compliant characters to -.
2. Modify test cases.

* 🐛 Bugfix: knowledge_base_search_tool called with TypeError: argument of type 'FieldInfo' is not iterable (#3259)

* 🐛 Bugfix: Fixed an issue where the one-click rename function failed after importing an agent. (#3258)

[Specification Details]
1. The frontend does not pass `agent_id` when calling the `regenerate_name` API.

* Bugfix: Exclude attachments from assistant when saving conversation history (#3261)

* Bump APP_VERSION from v2.2.0 to v2.2.1 (#3268)

The default setting for client-side self-validation is "False".

---------

Co-authored-by: chase <byzhangxin11@126.com>
Co-authored-by: Chenlifeng <174292121+Lifeng-Chen@users.noreply.github.com>
Co-authored-by: Dallas98 <40557804+Dallas98@users.noreply.github.com>
Co-authored-by: Jason Wang <56037774+JasonW404@users.noreply.github.com>
Co-authored-by: Xia Yichen <iamjasonxia@126.com>
Co-authored-by: JeffWu <45140512+jeffwu-1999@users.noreply.github.com>
Co-authored-by: WMC001 <46217886+WMC001@users.noreply.github.com>
Co-authored-by: xuyaqi <xuyaqist@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: DongJiBao2001 <120021235+DongJiBao2001@users.noreply.github.com>
Co-authored-by: hhhhsc701 <56435672+hhhhsc701@users.noreply.github.com>
Co-authored-by: Dallas98 <990259227@qq.com>
Co-authored-by: frr <64584192+wuyuanfr@users.noreply.github.com>

* Revert "Release/v2.2.1 (#3269)" (#3272)

This reverts commit 9ff420e.

* docs: add aidp knowledge base adapter design

* feat: add aidp knowledge base adapter

* Update .gitignore to include .omo directory for better file management

* ✨ Feature: Implement AIDP Management App with CRUD operations for knowledge bases

* 🐛 Fix: Correct file upload format in AIDP service and adjust headers in frontend to support multipart requests

* 🔧 Refactor: Simplify existing knowledge base name extraction and restore form values on modal remount

* ✨ Feature: Enhance AIDP knowledge base creation with default values and improved document handling

* 🔧 Refactor: Simplify AidpKnowledgeConfiguration by removing unused state and optimizing data fetching

* ✨ Feature: Introduce AIDP knowledge base management with dynamic routing and configuration options, including CRUD operations and feature flag integration for frontend visibility.

* ✨ Feature: Enhance AIDP knowledge base management with pagination support, total count retrieval, and improved document handling in the frontend. Implement server-side pagination and update UI components to reflect total items and availability of more pages.

* ✨ Feature: Implement AIDP document count retrieval and enhance pagination logic in the frontend. Introduce reliable total count handling for documents and knowledge bases, improving user experience with accurate pagination and display of total items.

* ✨ Feature: Refactor AIDP integration to read server URL and API key from environment variables, simplifying frontend components and enhancing security by removing direct credential handling. Update related services and components to streamline knowledge base management and document handling.

* ✨ Feature: Add support for listing AIDP models in the management app, enhancing knowledge base creation with dynamic VLM model selection. Update frontend components to fetch and display available models based on user input, improving user experience in multimodal knowledge base configuration.

* fix: add missing comma in common.json for toolConfig validation message

* ✨ feat: update AIDP knowledge base integration and routing

* ✨ feat: enhance AIDP knowledge base permissions and integration

* ✨ feat: implement AIDP permission subsystem exception handling and enhance knowledge base access control

* ✨ feat: enhance AIDP knowledge selector with pagination and total item count display

* ✨ feat: enhance AIDP integration with improved metadata handling, multimodal inference, and robust error logging

* ✨ Update AIDP integration: enhance search tools documentation, add AIDP search capabilities, and persist mock server state.

* ✨ Enhance AidpUpdateKbModal: Add group selection and permission management features, improving user experience for knowledge base updates.

* 🔒 Security: Improve API key handling and URL validation in AIDP services to prevent credential leakage and potential attacks.

* 🔒 Security: Enhance URL validation in AIDP image fetching to prevent SSRF vulnerabilities and improve defensive coding practices. Add comprehensive unit tests for AIDP client and exception handling to ensure robustness.

* 🔧 Refactor timestamp conversion logic in AIDP service: update handling of numeric zero and boolean values to correctly return Unix epoch timestamps. Enhance unit tests to verify behavior for edge cases, ensuring accurate conversion for various input types.

* Fix AIDP image tests: add AIDP_SERVER_URL monkeypatch

The stricter URL validation in _validate_and_reconstruct_aidp_url()
requires tests to explicitly set AIDP_SERVER_URL, otherwise the
validation rejects all URLs before reaching the API key/header logic.

* 🔒 Security: Refactor AIDP URL validation to enhance SSRF protection. The new `_validate_and_reconstruct_aidp_url` function ensures strict checks and re-serialization of URLs, improving safety against potential attacks. Update `_fetch_aidp_image` to utilize the new validation method, reinforcing defensive coding practices.

* Add ext_components path to test target paths

* test: comprehensive coverage improvements across AIDP, agents, and core services

Achieved 100% coverage for app_factory.py (AIDP exception handlers),
group_db.py (query functions), nexent_agent.py (all tool branches),
and AIDP search_tool.py.

Key coverage improvements:
- backend/apps/app_factory.py: 73% → 100% (17 lines)
  Added tests for all AIDP exception handlers including
  QuotaExceededError, AidpKbNotFoundError, AidpKbPermissionDeniedError,
  AidpKbConflictError, AidpKbSyncError, AidpGroupValidationError,
  ImportError fallback, and NexentCapabilityError.

- backend/database/group_db.py: 92% → 100% (10 lines)
  Added 14 tests covering query_group_ids_by_user_in_tenant and
  filter_tenant_group_ids with success, empty input, and soft-delete
  filtering scenarios.

- sdk/nexent/core/agents/nexent_agent.py: 82% → 100% (86 lines)
  Added 24 tests invoking monitoring wrappers, covering AidpSearchTool
  branch, CreatePlan/UpdatePlanStep tools, sandbox executor setup,
  plan tool wiring, token usage extraction, and MinIO sandbox cleanup.

- sdk/nexent/core/ext_components/aidp/aidp_search_tool.py: 75% → 100%
  Added tests for all search tool branches including error handling
  and configuration validation.

- backend/ext_components/aidp/: Achieved 100% coverage across all AIDP
  modules (mgmt_app, permission_db, permission_service) with 55+ new
  tests covering permission checks, group validation, and edge cases.

- backend/services/tool_configuration_service.py: 84% → 96%
  Added 13 tests for AIDP permission validation, tool validation,
  and error handling paths.

- backend/agents/create_agent_info.py: 84% → 93%
  Added 12 tests for memory formatting, memory service error handling,
  and AIDP credential injection during agent creation.

Total: 1097 tests pass across all modified files.

---------

Co-authored-by: panyehong <91180085+YehongPan@users.noreply.github.com>
Co-authored-by: chase <byzhangxin11@126.com>
Co-authored-by: Chenlifeng <174292121+Lifeng-Chen@users.noreply.github.com>
Co-authored-by: Dallas98 <40557804+Dallas98@users.noreply.github.com>
Co-authored-by: Jason Wang <56037774+JasonW404@users.noreply.github.com>
Co-authored-by: Xia Yichen <iamjasonxia@126.com>
Co-authored-by: JeffWu <45140512+jeffwu-1999@users.noreply.github.com>
Co-authored-by: WMC001 <46217886+WMC001@users.noreply.github.com>
Co-authored-by: xuyaqi <xuyaqist@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: hhhhsc701 <56435672+hhhhsc701@users.noreply.github.com>
Co-authored-by: Dallas98 <990259227@qq.com>
Co-authored-by: frr <64584192+wuyuanfr@users.noreply.github.com>
Co-authored-by: cang-xue <3232085039@qq.com>
* feat: implement turn resource handling and selection in agent workflow

* feat: implement turn resource handling and selection in agent workflow

* feat: add automation proposal parsing and rendering in conversation threads
@wjn1584
wjn1584 requested review from Dallas98 and WMC001 as code owners July 28, 2026 02:19
})
resp.append(combined)

return {"result": resp}
num=topk,
return_score=False
)
return {"result": results}
Comment on lines +415 to +418
return {
"result": [],
"error": str(e)
}
@wjn1584 wjn1584 changed the title 🐛 Bugfix: batch expor 🐛 Bugfix: batch import and export agent with skill Jul 28, 2026
@wjn1584 wjn1584 linked an issue Jul 28, 2026 that may be closed by this pull request
@bernard1234 bernard1234 changed the title 🐛 Bugfix: batch import and export agent with skill 🐛 Bugfix: import and export agent with skills Jul 28, 2026
@wjn1584 wjn1584 closed this Jul 28, 2026
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.

[Request] 支持带skills的agent的导入导出