test_execution_view_payload_v8.py 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. from app.execution_view_payload import compact_execution_view
  2. def test_main_payload_removes_decision_details_and_runtime_previews():
  3. source = {
  4. "schemaVersion": "8",
  5. "objective": {
  6. "decision": {
  7. "semanticKind": "decision",
  8. "card": {"primary": {"value": "目标"}},
  9. "detail": {"blocks": [{"value": "完整业务详情"}]},
  10. }
  11. },
  12. "rounds": [
  13. {
  14. "branches": [
  15. {
  16. "dataDecisions": [
  17. {
  18. "id": "data-decision:1",
  19. "recordId": 1,
  20. "reasoning": "原始理由",
  21. "sources": [{"post_id": "secret"}],
  22. "node": {"id": "data-decision:1", "card": {}},
  23. },
  24. ]
  25. },
  26. {
  27. "retrievalStage": {
  28. "agentRuns": [
  29. {
  30. "businessLabel": "知识 Agent",
  31. "agentType": "retrieve_data_knowledge",
  32. }
  33. ]
  34. }
  35. },
  36. ],
  37. "convergenceBatches": [
  38. {
  39. "review": {
  40. "id": "multipath-review:7",
  41. "eventId": 7,
  42. "roundIndex": 1,
  43. "branchIds": [1, 2],
  44. "status": "ok",
  45. "inputPreview": "完整任务",
  46. "outputPreview": "完整评审报告",
  47. "achievements": ["很长的报告内容"],
  48. "detailRef": "event:7",
  49. "decisionProjection": {
  50. "semanticKind": "decision",
  51. "card": {"primary": {"value": "通过"}},
  52. "detail": {"blocks": [{"value": "完整评审"}]},
  53. },
  54. }
  55. }
  56. ]
  57. }
  58. ],
  59. }
  60. result = compact_execution_view(source)
  61. assert "detail" not in result["objective"]["decision"]
  62. review = result["rounds"][0]["convergenceBatches"][0]["review"]
  63. assert "inputPreview" not in review
  64. assert "outputPreview" not in review
  65. assert "achievements" not in review
  66. assert "detail" not in review["decisionProjection"]
  67. data_decision = result["rounds"][0]["branches"][0]["dataDecisions"][0]
  68. assert data_decision == {
  69. "id": "data-decision:1",
  70. "node": {"id": "data-decision:1", "card": {}},
  71. }
  72. agent_run = result["rounds"][0]["branches"][1]["retrievalStage"]["agentRuns"][0]
  73. assert agent_run == {"businessLabel": "知识 Agent"}
  74. assert "retrieve_data_" not in str(result)
  75. assert source["objective"]["decision"]["detail"]