Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: content type for agent messages #109

Open
saulmc opened this issue Nov 5, 2024 · 0 comments
Open

Feature request: content type for agent messages #109

saulmc opened this issue Nov 5, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@saulmc
Copy link
Member

saulmc commented Nov 5, 2024

Is your feature request related to a problem?

Other clients have no way of knowing whether a message was sent by a human or an agent.

Describe the solution to the problem

Use TextEncoder() with a new agent-message ContentTypeId for all generated messages. This is not a trustless solution.

e.g.

import {
  ContentTypeId,
  ContentCodec,
  EncodedContent,
} from "@xmtp/content-type-primitives";

export const ContentTypeAgentMessage = new ContentTypeId({
  authorityId: "xmtp.org",
  typeId: "agent-message",
  versionMajor: 1,
  versionMinor: 0,
});

export class AgentMessageCodec implements ContentCodec<string> {
  contentType = ContentTypeAgentMessage;

  encode(content: string): EncodedContent {
    return {
      type: this.contentType,
      parameters: {},
      content: new TextEncoder().encode(content),
      fallback: content,
    };
  }

  decode(encodedContent: EncodedContent): string {
    return new TextDecoder().decode(encodedContent.content);
  }

  fallback(content: string): string | undefined {
    return content;
  }

  shouldPush(): boolean {
    return true;
  }
}

Describe the uses cases for the feature

A client like Converse may wish to display messages differently if they are known to be agents.

An agent may want to handle agent-generated messages differently from messages assumed to be from humans. For instance, an agent may wish to ignore other agents to prevent loops.

Additional details

No response

@saulmc saulmc added the enhancement New feature or request label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant