Skip to content

feat: share multi turn, multi attempt with artifact viewing#715

Merged
Henry-811 merged 6 commits intodev/v0.1.32from
001-share-multi-turn
Dec 31, 2025
Merged

feat: share multi turn, multi attempt with artifact viewing#715
Henry-811 merged 6 commits intodev/v0.1.32from
001-share-multi-turn

Conversation

@ncrispino
Copy link
Collaborator

@ncrispino ncrispino commented Dec 31, 2025

Pull Request: Multi-Turn Session Sharing & Restart Support

Summary

This PR enhances the massgen export command to support sharing multi-turn sessions with multiple attempts. It includes improved logging infrastructure for restart tracking, artifact viewer support for MassGen-Viewer, Office document PDF conversion upon export for previews, and viewer enhancements to navigate between turns and attempts.

Features

1. Multi-Turn Session Sharing

Share entire multi-turn conversations with all turns and attempts preserved:

# Share all turns (default)
massgen export

# Share specific turn range
massgen export --turns 2-5

# Share only the latest turn
massgen export --turns latest

# Preview what would be shared
massgen export --dry-run --verbose

New CLI Options:

Option Description
--turns / -t Turn range: "all", "N" (1-N), "N-M", or "latest"
--no-workspace Exclude workspace artifacts
--workspace-limit Max workspace size per agent (e.g., "500KB", "1MB")
--yes / -y Skip interactive prompts
--dry-run Preview without creating gist
--verbose / -v Show detailed file listing
--json Output result as JSON (for scripting)

2. Attempt/Restart Tracking

Each orchestration restart now gets its own attempt directory with separate logs:

log_20251230_201653/
├── turn_1/
│   ├── attempt_1/           # First attempt (restarted)
│   │   ├── massgen.log
│   │   ├── execution_metadata.yaml
│   │   ├── metrics_summary.json
│   │   └── agent_outputs/
│   └── attempt_2/           # Second attempt (successful)
│       ├── massgen.log
│       ├── execution_metadata.yaml
│       ├── metrics_summary.json
│       └── agent_outputs/
  • Log file handlers are reconfigured on restart to write to new attempt directory
  • Execution metadata is saved for each attempt with restart reason
  • Status tracking distinguishes "restarted" vs "complete" attempts

3. Office Document PDF Conversion

DOCX, PPTX, and XLSX files are automatically converted to PDF for preview in the viewer:

  • Original Office document included (for download)
  • PDF version included (for in-browser preview)
  • Uses Docker + LibreOffice via ghcr.io/massgen/mcp-runtime:latest
  • Graceful fallback if Docker unavailable

4. Session Manifest

Exports now include a _session_manifest.json with session-level metadata:

{
  "version": "2.0",
  "session_id": "log_20251230_201653",
  "total_cost": 1.2056,
  "total_tokens": {"input": 1694743, "output": 12865},
  "turn_count": 1,
  "attempt_count": 2,
  "question": "Create a simple two slide pptx presentation",
  "winner": "agent_a",
  "turns": [
    {"turn_number": 1, "attempt_number": 1, "status": "restarted"},
    {"turn_number": 1, "attempt_number": 2, "status": "complete", "winner": "agent_a"}
  ]
}

5. Clean Final Answers (Claude Code)

The final presentation content now excludes tool call/result noise for Claude Code:

Before: Final answer included 🔧 tool_name(...) and 🔧 Tool ✅ Result: {...} lines

After: Final answer contains only the clean text response, making it suitable for:

  • answer.txt files
  • Post-evaluation context
  • Conversation history display

6. Viewer Enhancements (MassGen-Viewer)

The web viewer supports artifact viewing using the same code as the webui. This allows people to see the artifacts within the viewer by clicking Preview on participating file types instead of needing to download the files themselves then open.

Additionally, there is now multi-turn and multi-attempt navigation:

  • Turn/Attempt Tabs: Navigate between attempts using compound keys (1_1, 1_2)
  • Attempt Status Icons: for restarted, for complete
  • Accurate Header: Shows "Turn: 1 (2 attempts)" instead of "2 turns"
  • Conversation History: Deduplicated to show one entry per turn (last attempt)
  • Claude Code Backend Note: Shows asterisk and explanation when tool metrics aren't tracked

Files Changed

File Changes
massgen/share.py Multi-turn collection, Office→PDF conversion, session manifest generation
massgen/session_exporter.py find_session_root(), get_session_turns(), parse_turn_range(), enhanced export_command()
massgen/cli.py New export CLI options, execution metadata on restart
massgen/logger_config.py set_log_attempt() reconfigures file handlers for new attempt directory
massgen/orchestrator.py Clean answer extraction (excludes tool calls), restart coordination
massgen/filesystem_manager/_constants.py Added OFFICE_DOCUMENT_EXTENSIONS
massgen/frontend/coordination_ui.py Updated for restart support
massgen/frontend/displays/*.py Display updates for restart handling
docs/source/user_guide/logging.rst Documented multi-turn export options
massgen/tests/test_share_multi_turn.py New test suite for multi-turn sharing
massgen/tests/test_orchestration_restart.py New tests for restart functionality

Known Limitations

  • Claude Code Backend: Tool call metrics are not tracked because Claude Code runs as a subprocess that handles its own tool execution. The viewer shows "0*" with explanation.

Test Plan

  • Multi-turn sessions export with all turns and attempts
  • Turn range parsing works for "all", "N", "N-M", "latest"
  • Office documents converted to PDF when Docker available
  • Session manifest includes correct metadata
  • Viewer displays attempt navigation correctly
  • Switching between attempts updates all sections (stats, timeline, answers)
  • Clean final answers exclude tool call noise
  • Restart creates new attempt directory with separate logs
# Run unit tests
uv run pytest massgen/tests/test_share_multi_turn.py -v
uv run pytest massgen/tests/test_orchestration_restart.py -v

# Test export
massgen export --dry-run --verbose

# Test with actual gist creation
massgen export --turns all

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated
  • Tests added for new functionality
  • No new test failures introduced
  • Imports at top of files

@ncrispino ncrispino changed the title feat: 001 share multi turn feat: share multi turn, multi attempt with artifact viewing Dec 31, 2025
@Henry-811 Henry-811 changed the base branch from main to dev/v0.1.32 December 31, 2025 17:13
@Henry-811 Henry-811 merged commit 303bc60 into dev/v0.1.32 Dec 31, 2025
21 checks passed
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