"Cannot read properties of undefined (reading 'role')" — triggered on every prompt, even with empty context. Seems like a middleware or handler bug with no fallback on missing role

Sorry everyone, @Sertac_Firat is right.

What happened here is we landed the first of a few fixes for long histories, but did not account for users who may have been working around this issue locally, i.e. by clearing their histories.

I have a fix ready for this, but it could be a few days before it rolls to prod.

In the meantime, the only option is to ensure a user and model turn are in the history. The safest way to do this is to create a new workspace, and to copy the structure of the context.json from the known good workspace. The other option is to try and do this manually, and in that case you want something like:

{
  "currentProposalObject": {...},
  "agentHistories": {
    "app-prototyping-agent: proposal-agent": [
      {
        "role": "user",
        "content": [
          {
            "text": "..."
          }
        ]
      },
      {
        "role": "model",
        "content": [
          {
            "text": "..."
          }
        ]
      }
    ],
    "app-prototyping-agent: edit-app-agent": [
      {
        "role": "user",
        "content": [
          {
            "text": "..."
          }
        ]
      },
      {
        "role": "model",
        "content": [
          {
            "text": "..."
          }
        ]
      }
    ]
  },
  "currentState": "edit-app"
}

My apologies if this is confusing, or if the workaround doesn’t quite work in all cases. We’ll have a proper fix rolled out to prod next week.