Skip to content

fix: normalize LLM profile fields at one boundary - #737

Merged
666ghj merged 3 commits into
mainfrom
agent/round2-pr-161-exec
Jul 22, 2026
Merged

fix: normalize LLM profile fields at one boundary#737
666ghj merged 3 commits into
mainfrom
agent/round2-pr-161-exec

Conversation

@666ghj

@666ghj 666ghj commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • normalize LLM-generated profile fields once in OasisAgentProfile.__post_init__
  • convert structured scalar values into stable text
  • recursively flatten nested topic values into list[str]
  • normalize MBTI alongside the other profile fields
  • keep serializers focused on output rather than repeating coercion policy

Why

PR #161 correctly identified that structured JSON values can reach fields later treated as strings. Its original implementation repeated slightly different coercion rules during parsing, object construction, and serialization; it could emit the literal text None, leave nested topics unstable, and did not normalize MBTI.

The maintained version establishes one canonical object boundary so every downstream serializer sees the same valid profile shape.

Validation

  • uv run pytest -q tests/test_profile_field_normalization.py — 4 passed
  • covered None, Unicode, nested dictionaries/lists, direct construction, Twitter CSV, and Reddit JSON
  • Python compileall passed
  • git diff --check passed
  • reconstructed on the current main branch

Preserves the original contributor commit and supersedes #161.

Fixes #154

🤖 Sent by the MiroFish repository maintenance agent.

@666ghj 666ghj added LLM API Any questions regarding the LLM API size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 22, 2026
@666ghj
666ghj merged commit 4064b68 into main Jul 22, 2026
@666ghj
666ghj deleted the agent/round2-pr-161-exec branch July 22, 2026 12:17
brovzar-lab pushed a commit to brovzar-lab/MiroFish-Lemon that referenced this pull request Jul 28, 2026
Brings in: Zep memory cap for long runs (OOM fix, PR 666ghj#730), zep-cloud 3.25
modernization + barrier tests (666ghj#738-740), profile normalization (666ghj#737),
honest FAILED states (666ghj#732/666ghj#735), fabricated tool_result stripping (666ghj#734),
ontology JSON hardening + long-text sampling (666ghj#742/666ghj#584), GPT-5 param
compat (666ghj#736), Twitter-only data fix (666ghj#733), security fixes (666ghj#445/666ghj#727).

Conflict resolutions:
- llm_client.py: upstream compat-layer base + Lemon CreditExhaustedException
  (402 -> pause/Resume) re-added in _create_completion
- api/report.py: upstream barrier/lifecycle base + Lemon failed-report
  resume (reuse report_id), project-language locale for report thread,
  title-based download filename, 404 on empty download
- report_agent.py: upstream cleaned_response/tool_result stripping kept;
  Lemon language-instruction injection + partial-report salvage intact
- Step3Simulation.vue: upstream authoritative runner_status (drops Lemon
  platformsCompleted shortcut, superseded by the Zep ingestion barrier)

139 backend tests pass; vite build clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LLM API Any questions regarding the LLM API size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Profile serialization crashes when LLM returns structured bio/persona fields

2 participants