Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(agents): include project context in task assignment prompts (#7378)

Eric Hayes1c152b1848e7
diff --git a/crates/agent_trigger/src/domain/task_assignment.rs b/crates/agent_trigger/src/domain/task_assignment.rs
index 3ab4551c16..0439f5a18e 100644
--- a/crates/agent_trigger/src/domain/task_assignment.rs
+++ b/crates/agent_trigger/src/domain/task_assignment.rs
@@ -17,6 +17,9 @@ use models_properties::{EntityType, service::property_value::PropertyValue};
use properties::domain::events::EntityPropertyUpdatedMetadata;
use system_properties::SystemPropertyKey;
+mod project_context;
+pub use project_context::ProjectTaskAssignmentContext;
+
use super::{
broker_events::{AgentAssignedToTaskEvent, AgentSessionMacroEvent, NewAgentSessionEvent},
processing::ProcessMessageEventError,
@@ -36,6 +39,8 @@ pub struct TaskBrief {
pub title: String,
/// Current task description in Markdown.
pub markdown: String,
+ /// Current project, only when the assigning principal can view it.
+ pub project_id: Option<initiative::domain::models::InitiativeId>,
}
/// Reads the task through its owning service under a verified document capability.
@@ -198,12 +203,25 @@ fn discussion_id(event_id: Uuid, bot_id: BotId) -> Uuid {
}
fn assignment_prompt(assignment: &TaskAssignment, brief: &TaskBrief) -> String {
- format!(
- "{}\n\n{}\n\n{}",
+ let mut prompt = format!(
+ "{}\n\n{}",
include_str!("task_assignment/prompt.md").trim(),
task_reference(&assignment.parent, &brief.title),
- brief.markdown,
- )
+ );
+ if let Some(project_id) = brief.project_id {
+ let project_reference = serde_json::json!({
+ "documentId": project_id,
+ "documentName": "Task project",
+ "blockName": "initiative",
+ "blockParams": {},
+ });
+ prompt.push_str(&format!(
+ "\n\nProject: <m-document-mention>{project_reference}</m-document-mention>"
+ ));
+ }
+ prompt.push_str("\n\n");
+ prompt.push_str(&brief.markdown);
+ prompt
}
/// Persistent task guidance for session system instructions, without snapshotting
diff --git a/crates/agent_trigger/src/domain/task_assignment/project_context.rs b/crates/agent_trigger/src/domain/task_assignment/project_context.rs
new file mode 100644
index 0000000000..fa560bb8d1
--- /dev/null
+++ b/crates/agent_trigger/src/domain/task_assignment/project_context.rs
@@ -0,0 +1,87 @@
+//! Current project context for an authorized task assignment.
+
+use agent_session::domain::error::{AgentSessionError, Result};
+use channel_sender::ChannelSender;
+use entity_access::domain::models::{EntityAccessAuth, EntityAccessReceipt};
+use initiative::domain::events::InitiativeEventActor;
+use messages::domain::service::MessageWrite;
+
+use crate::domain::project_assignment::{ProjectAssignmentAccess, ProjectMemberships};
+
+use super::{TaskAssignmentContext, TaskBrief};
+
+#[cfg(test)]
+mod test;
+
+/// Enriches task briefs with the current project only when the same actor can view it.
+pub struct ProjectTaskAssignmentContext<C, M, A> {
+ tasks: C,
+ memberships: M,
+ access: A,
+}
+
+impl<C, M, A> ProjectTaskAssignmentContext<C, M, A> {
+ /// Compose task content, current memberships, and project authorization ports.
+ pub fn new(tasks: C, memberships: M, access: A) -> Self {
+ Self {
+ tasks,
+ memberships,
+ access,
+ }
+ }
+}
+
+impl<C, M, A> TaskAssignmentContext for ProjectTaskAssignmentContext<C, M, A>
+where
+ C: TaskAssignmentContext,
+ M: ProjectMemberships + 'static,
+ A: ProjectAssignmentAccess + 'static,
+{
+ async fn task_brief(
+ &self,
+ access: EntityAccessReceipt<MessageWrite>,
+ ) -> Result<Option<TaskBrief>> {
+ let Some(mut brief) = self.tasks.task_brief(access.clone()).await? else {
+ return Ok(None);
+ };
+ // Membership may have changed since another source built the brief.
+ brief.project_id = None;
+ let actor = match access.auth() {
+ EntityAccessAuth::Authenticated(user) => InitiativeEventActor {
+ actor: ChannelSender::new_from_user(user.clone()),
+ on_behalf_of: None,
+ },
+ EntityAccessAuth::Bot(bot) => {
+ let Some(user) = bot.scope().acting_user_id() else {
+ return Ok(Some(brief));
+ };
+ InitiativeEventActor {
+ actor: ChannelSender::new_from_bot(bot.bot_id()),
+ on_behalf_of: Some(user.clone()),
+ }
+ }
+ EntityAccessAuth::Unauthenticated | EntityAccessAuth::Internal => {
+ return Ok(Some(brief));
+ }
+ };
+ let task = &access.entity().entity_id;
+ let memberships = self
+ .memberships
+ .memberships(vec![task.clone()])
+ .await
+ .map_err(|error| AgentSessionError::Unknown(error.into()))?;
+ let Some(project) = memberships.get(task).copied() else {
+ return Ok(Some(brief));
+ };
+ if self
+ .access
+ .receipts(&actor, project, task)
+ .await
+ .map_err(|error| AgentSessionError::Unknown(error.into()))?
+ .is_some()
+ {
+ brief.project_id = Some(project);
+ }
+ Ok(Some(brief))
+ }
+}
diff --git a/crates/agent_trigger/src/domain/task_assignment/project_context/test.rs b/crates/agent_trigger/src/domain/task_assignment/project_context/test.rs
new file mode 100644
index 0000000000..044cdaea6b
--- /dev/null
+++ b/crates/agent_trigger/src/domain/task_assignment/project_context/test.rs
@@ -0,0 +1,245 @@
+use super::*;
+use crate::domain::{
+ project_assignment::{MockProjectAssignmentAccess, MockProjectMemberships},
+ task_assignment::MockTaskAssignmentContext,
+};
+use bot_id::BotId;
+use entity_access::domain::models::{
+ AccessError, AccessLevel, BotReceiptScope, Entity, EntityPermission, EntityType,
+ RequiredPermission,
+};
+use initiative::domain::models::{InitiativeError, InitiativeId};
+use macro_user_id::user_id::MacroUserIdStr;
+use properties::{EditReceipt, ViewReceipt};
+use std::collections::HashMap;
+
+fn user() -> MacroUserIdStr<'static> {
+ MacroUserIdStr::try_from_email("[email protected]").unwrap()
+}
+
+fn receipt<T: RequiredPermission>(id: &str, entity_type: EntityType) -> EntityAccessReceipt<T> {
+ EntityAccessReceipt::try_new_authenticated_user(
+ user(),
+ Entity {
+ entity_id: id.to_owned(),
+ entity_type,
+ },
+ EntityPermission::AccessLevel {
+ access_level: AccessLevel::Edit,
+ },
+ )
+ .unwrap()
+}
+
+fn task_access() -> EntityAccessReceipt<MessageWrite> {
+ receipt("task", EntityType::Document)
+}
+
+fn bot_access(scope: BotReceiptScope) -> EntityAccessReceipt<MessageWrite> {
+ EntityAccessReceipt::try_new_bot(
+ BotId::TEST_A.into_storage_id(),
+ scope,
+ Entity {
+ entity_id: "task".to_owned(),
+ entity_type: EntityType::Document,
+ },
+ EntityPermission::AccessLevel {
+ access_level: AccessLevel::Edit,
+ },
+ )
+ .unwrap()
+}
+
+fn brief() -> TaskBrief {
+ TaskBrief {
+ title: "Fix export".to_owned(),
+ markdown: "Include archived rows.".to_owned(),
+ project_id: Some(InitiativeId::generate()),
+ }
+}
+
+fn tasks(value: Option<TaskBrief>) -> MockTaskAssignmentContext {
+ let mut tasks = MockTaskAssignmentContext::new();
+ tasks
+ .expect_task_brief()
+ .once()
+ .withf(|access| access.entity().entity_id == "task")
+ .return_once(move |_| Box::pin(async move { Ok(value) }));
+ tasks
+}
+
+fn membership(project: Option<InitiativeId>) -> MockProjectMemberships {
+ let mut memberships = MockProjectMemberships::new();
+ memberships
+ .expect_memberships()
+ .once()
+ .withf(|ids| ids == &["task"])
+ .return_once(move |_| {
+ Box::pin(async move {
+ Ok(project
+ .map(|id| HashMap::from([("task".to_owned(), id)]))
+ .unwrap_or_default())
+ })
+ });
+ memberships
+}
+
+fn allowed(
+ _: &InitiativeEventActor,
+ project: InitiativeId,
+ task: &str,
+) -> std::pin::Pin<
+ Box<
+ dyn Future<Output = std::result::Result<Option<(ViewReceipt, EditReceipt)>, AccessError>>
+ + Send,
+ >,
+> {
+ let result = (
+ receipt(&project.to_string(), EntityType::Initiative),
+ receipt(task, EntityType::Document),
+ );
+ Box::pin(async move { Ok(Some(result)) })
+}
+
+#[tokio::test]
+async fn current_project_replaces_stale_context_after_authorizing_the_same_user() {
+ let project = InitiativeId::generate();
+ let original = brief();
+ let mut access = MockProjectAssignmentAccess::new();
+ access
+ .expect_receipts()
+ .once()
+ .withf(move |actor, id, task| {
+ actor.actor.as_user() == Some(&user())
+ && actor.on_behalf_of.is_none()
+ && *id == project
+ && task == "task"
+ })
+ .returning(allowed);
+ let result = ProjectTaskAssignmentContext::new(
+ tasks(Some(original.clone())),
+ membership(Some(project)),
+ access,
+ )
+ .task_brief(task_access())
+ .await
+ .unwrap()
+ .unwrap();
+ assert_eq!(result.project_id, Some(project));
+ assert_eq!(result.title, original.title);
+ assert_eq!(result.markdown, original.markdown);
+}
+
+#[tokio::test]
+async fn delegated_bot_keeps_its_identity_and_acting_user_for_project_access() {
+ let project = InitiativeId::generate();
+ let mut access = MockProjectAssignmentAccess::new();
+ access
+ .expect_receipts()
+ .once()
+ .withf(|actor, _, _| {
+ actor.actor.as_bot().map(|id| id.bot_id()) == Some(BotId::TEST_A)
+ && actor.on_behalf_of.as_ref() == Some(&user())
+ })
+ .returning(allowed);
+ let result =
+ ProjectTaskAssignmentContext::new(tasks(Some(brief())), membership(Some(project)), access)
+ .task_brief(bot_access(BotReceiptScope::User {
+ acting_user: user(),
+ }))
+ .await
+ .unwrap()
+ .unwrap();
+ assert_eq!(result.project_id, Some(project));
+}
+
+#[tokio::test]
+async fn no_project_or_revoked_access_removes_stale_project_context() {
+ for project in [None, Some(InitiativeId::generate())] {
+ let mut access = MockProjectAssignmentAccess::new();
+ if project.is_some() {
+ access
+ .expect_receipts()
+ .once()
+ .returning(|_, _, _| Box::pin(async { Ok(None) }));
+ }
+ let result =
+ ProjectTaskAssignmentContext::new(tasks(Some(brief())), membership(project), access)
+ .task_brief(task_access())
+ .await
+ .unwrap()
+ .unwrap();
+ assert_eq!(result.project_id, None);
+ }
+}
+
+#[tokio::test]
+async fn missing_tasks_do_not_read_project_membership() {
+ let result = ProjectTaskAssignmentContext::new(
+ tasks(None),
+ MockProjectMemberships::new(),
+ MockProjectAssignmentAccess::new(),
+ )
+ .task_brief(task_access())
+ .await
+ .unwrap();
+ assert!(result.is_none());
+}
+
+#[tokio::test]
+async fn receipts_without_an_acting_user_do_not_expose_project_context() {
+ let internal =
+ EntityAccessReceipt::dangerously_assert_internal_user("task", EntityType::Document);
+ let team_bot = bot_access(BotReceiptScope::Team {
+ team_id: macro_uuid::Uuid::now_v7(),
+ });
+ for receipt in [internal, team_bot] {
+ let result = ProjectTaskAssignmentContext::new(
+ tasks(Some(brief())),
+ MockProjectMemberships::new(),
+ MockProjectAssignmentAccess::new(),
+ )
+ .task_brief(receipt)
+ .await
+ .unwrap()
+ .unwrap();
+ assert_eq!(result.project_id, None);
+ }
+}
+
+#[tokio::test]
+async fn project_membership_and_access_failures_are_retried() {
+ let mut memberships = MockProjectMemberships::new();
+ memberships.expect_memberships().once().returning(|_| {
+ Box::pin(async {
+ Err(InitiativeError::Internal(
+ std::io::Error::other("database unavailable").into(),
+ ))
+ })
+ });
+ let result = ProjectTaskAssignmentContext::new(
+ tasks(Some(brief())),
+ memberships,
+ MockProjectAssignmentAccess::new(),
+ )
+ .task_brief(task_access())
+ .await;
+ assert!(matches!(result, Err(AgentSessionError::Unknown(_))));
+
+ let mut access = MockProjectAssignmentAccess::new();
+ access.expect_receipts().once().returning(|_, _, _| {
+ Box::pin(async {
+ Err(AccessError::Unavailable(
+ std::io::Error::other("access unavailable").into(),
+ ))
+ })
+ });
+ let result = ProjectTaskAssignmentContext::new(
+ tasks(Some(brief())),
+ membership(Some(InitiativeId::generate())),
+ access,
+ )
+ .task_brief(task_access())
+ .await;
+ assert!(matches!(result, Err(AgentSessionError::Unknown(_))));
+}
diff --git a/crates/agent_trigger/src/domain/task_assignment/prompt.md b/crates/agent_trigger/src/domain/task_assignment/prompt.md
index b66e3a370f..1694bd9e20 100644
--- a/crates/agent_trigger/src/domain/task_assignment/prompt.md
+++ b/crates/agent_trigger/src/domain/task_assignment/prompt.md
@@ -1,5 +1,7 @@
You've been assigned the original Macro task linked below. Carry out its requested work and keep that task up to date using the available Macro tools.
+If the assignment includes a project link, read the project's current description before starting the task and use it to understand the project's goals and requirements. Call ReadInitiative using the project reference's documentId as initiativeId, then ReadContent using the returned project's descriptionDocumentId as documentId. If you cannot read the description, explain the limitation in the agent session.
+
Read the current task before editing it. Update its description when useful to capture clarified requirements, relevant findings, decisions, or results, preserving existing context and other people's edits. Update its status to reflect actual progress; mark it completed only when the requested work is complete. Task properties use entity_type="document" and the original task's documentId.
Do not post, edit, or delete messages in the task's discussion unless the user explicitly asks you to. Being assigned a task, including through a project, is not a request to report progress in its discussion. Give progress reports, results, and clarification questions in the agent session instead. If the available tools cannot update the task, explain that in the session rather than claiming an update succeeded.
diff --git a/crates/agent_trigger/src/domain/task_assignment/test.rs b/crates/agent_trigger/src/domain/task_assignment/test.rs
index b0fa997cfd..1a04c0283e 100644
--- a/crates/agent_trigger/src/domain/task_assignment/test.rs
+++ b/crates/agent_trigger/src/domain/task_assignment/test.rs
@@ -10,6 +10,7 @@ fn brief() -> TaskBrief {
TaskBrief {
title: "Fix export".to_owned(),
markdown: "Include archived rows in CSV exports.".to_owned(),
+ project_id: None,
}
}
@@ -31,6 +32,15 @@ fn task_references_preserve_identity_without_allowing_markup_injection() {
assert!(assignment_instructions(&parent).contains(r#""documentId":"original-task""#));
}
+#[test]
+fn assignments_without_a_project_keep_only_the_original_task_reference() {
+ let assignment = TaskAssignment::from_update(Uuid::now_v7(), &update()).unwrap();
+ let prompt = assignment_prompt(&assignment, &brief());
+ assert_eq!(prompt.matches("<m-document-mention>").count(), 1);
+ assert!(!prompt.contains("Project: "));
+ assert!(prompt.ends_with(&brief().markdown));
+}
+
fn value(ids: &[&str]) -> Option<PropertyValue> {
Some(PropertyValue::EntityRef(
ids.iter()
@@ -362,12 +372,20 @@ async fn authorized_assignment_publishes_the_task_brief_for_toolless_runtimes()
MockImplicitTriggerJudge::new(),
history,
);
+ let project_id = initiative::domain::models::InitiativeId::generate();
let mut context = MockTaskAssignmentContext::new();
context
.expect_task_brief()
.once()
.withf(|access| access.entity().entity_id == "task-1")
- .returning(|_| Box::pin(async { Ok(Some(brief())) }));
+ .returning(move |_| {
+ Box::pin(async move {
+ Ok(Some(TaskBrief {
+ project_id: Some(project_id),
+ ..brief()
+ }))
+ })
+ });
let mut commands = MockMessageCommands::new();
let mut message = discussion(&assignment);
message.id = event_id;
@@ -392,6 +410,25 @@ async fn authorized_assignment_publishes_the_task_brief_for_toolless_runtimes()
assert!(prompt.contains("Fix export"));
assert!(prompt.contains("Include archived rows in CSV exports."));
assert!(prompt.contains(r#""documentId":"task-1""#));
+ let project_mention = prompt
+ .split("Project: <m-document-mention>")
+ .nth(1)
+ .unwrap()
+ .split("</m-document-mention>")
+ .next()
+ .unwrap();
+ let project: serde_json::Value = serde_json::from_str(project_mention).unwrap();
+ assert_eq!(project["documentId"], project_id.to_string());
+ assert_eq!(project["blockName"], "initiative");
+ for instructions in [
+ prompt.to_owned(),
+ assignment_instructions(&assignment.parent),
+ ] {
+ assert!(instructions.contains("read the project's current description before starting"));
+ assert!(instructions.contains("ReadInitiative"));
+ assert!(instructions.contains("ReadContent"));
+ assert!(instructions.contains("descriptionDocumentId"));
+ }
assert_eq!(metadata["parent"]["type"], "document");
}
diff --git a/crates/agent_trigger/src/outbound/dss_task_assignment_context.rs b/crates/agent_trigger/src/outbound/dss_task_assignment_context.rs
index 1216cf04c0..6b96bb4de9 100644
--- a/crates/agent_trigger/src/outbound/dss_task_assignment_context.rs
+++ b/crates/agent_trigger/src/outbound/dss_task_assignment_context.rs
@@ -58,6 +58,7 @@ impl TaskAssignmentContext for DssTaskAssignmentContext {
Ok(Some(TaskBrief {
title: document.document_name,
markdown,
+ project_id: None,
}))
}
}
diff --git a/docs/AGENT_GUIDE/tasks.md b/docs/AGENT_GUIDE/tasks.md
index f9b56cbe95..e2376eaa67 100644
--- a/docs/AGENT_GUIDE/tasks.md
+++ b/docs/AGENT_GUIDE/tasks.md
@@ -295,8 +295,10 @@ session; progress and final answers stay in that session. The agent retains the
original task reference in its session instructions and updates the task's
description or status as appropriate. It must not post or edit discussion messages
unless explicitly asked. This also applies to task assignments inherited from a
-project. The assignment instructions and task details are private startup context;
-no message is posted as you. People and agents
+project. When the task belongs to a project the assigning user can view, the
+startup prompt links that project and tells the agent to read its current
+description before starting work. The assignment instructions and task details
+are private startup context; no message is posted as you. People and agents
can remain assigned together. Removing an agent and saving, then assigning it
again starts a new session; saving an unchanged assignment does not restart it.
diff --git a/packages/lexical-core/tests/agent-context.test.ts b/packages/lexical-core/tests/agent-context.test.ts
index c22331b21b..aa4eefe6a4 100644
--- a/packages/lexical-core/tests/agent-context.test.ts
+++ b/packages/lexical-core/tests/agent-context.test.ts
@@ -155,6 +155,64 @@ const origin =
'This prompt was posted in a channel thread, not the agent session view. Your reply is posted back into that thread, and it is where the user will answer anything you ask.';
describe('composeAgentContextPrompt', () => {
+ it('preserves task and project references and reading guidance in an assignment prompt', () => {
+ const taskId = '019a048e-3664-77a4-b76b-02b9d67db5e8';
+ const projectId = '019a048e-3664-77a4-b76b-02b9d67db5e9';
+ const task = `<m-document-mention>${JSON.stringify({
+ documentId: taskId,
+ documentName: 'Fix the launch checklist',
+ blockName: 'task',
+ blockParams: {},
+ })}</m-document-mention>`;
+ const project = `<m-document-mention>${JSON.stringify({
+ documentId: projectId,
+ documentName: 'Task project',
+ blockName: 'initiative',
+ blockParams: {},
+ })}</m-document-mention>`;
+ const guidance =
+ "Read the project's current description before starting. Call ReadInitiative with the linked project's initiativeId, then ReadContent with the returned project's descriptionDocumentId.";
+ const composed = composeAgentContextPrompt({
+ promptMarkdown: `You were assigned ${task}.\n\nProject: ${project}. ${guidance}`,
+ });
+ const serialized = markdownToSerializedEditorStateWithIds(composed);
+ expect(serialized.root.children).toMatchObject([
+ {
+ children: [
+ { type: 'text', text: 'You were assigned ' },
+ {
+ type: 'document-mention',
+ documentId: taskId,
+ blockName: 'task',
+ },
+ { type: 'text', text: '.' },
+ ],
+ },
+ {
+ children: [
+ { type: 'text', text: 'Project: ' },
+ {
+ type: 'document-mention',
+ documentId: projectId,
+ documentName: 'Task project',
+ blockName: 'initiative',
+ },
+ { type: 'text', text: `. ${guidance}` },
+ ],
+ },
+ ]);
+ const editor = createHeadlessEditor({
+ nodes: [...SupportedNodeTypes, ...NodeReplacements],
+ });
+ const state = editor.parseEditorState(serialized);
+
+ const exported = state.read(() =>
+ $convertToMarkdownString(EXTERNAL_TRANSFORMERS)
+ );
+ expect(exported).toBe(composed);
+ expect(exported).toContain(guidance);
+ });
+
it('keeps the prompt thread whole and the rest of the channel as grouped background', () => {
expect(
composedContext({
diff --git a/services/agent_harness_service/src/trigger.rs b/services/agent_harness_service/src/trigger.rs
index dd52ac5e9e..438239f95f 100644
--- a/services/agent_harness_service/src/trigger.rs
+++ b/services/agent_harness_service/src/trigger.rs
@@ -5,7 +5,9 @@ use agent_trigger::domain::processing::process_message_event;
use agent_trigger::domain::project_assignment::ProjectAssignmentService;
use agent_trigger::domain::service::AgentTriggerService;
use agent_trigger::domain::sources::{MessageTriggerEvents, TriggerEvents};
-use agent_trigger::domain::task_assignment::process_task_assignment;
+use agent_trigger::domain::task_assignment::{
+ ProjectTaskAssignmentContext, TaskAssignmentContext, process_task_assignment,
+};
use agent_trigger::outbound::{
BotRepoAgentLookup, ChannelRepoTypeLookup, DssTaskAssignmentContext, FastModelTriggerJudge,
LexicalExplicitReplyExtractor, MessageThreadHistory, VisionImageCaptioner,
@@ -138,12 +140,16 @@ async fn run(
messages,
} = services;
let lexical = LexicalClient::new(internal_api_key, LexicalServiceUrl::new()?.to_string());
- let task_context = DssTaskAssignmentContext::new(
- DocumentStorageServiceClient::new(
- document_storage_service_auth_key,
- DocumentStorageServiceUrl::new()?.to_string(),
+ let task_context = ProjectTaskAssignmentContext::new(
+ DssTaskAssignmentContext::new(
+ DocumentStorageServiceClient::new(
+ document_storage_service_auth_key,
+ DocumentStorageServiceUrl::new()?.to_string(),
+ ),
+ lexical.clone(),
),
- lexical.clone(),
+ PgInitiativeRepo::new(pool.clone()),
+ EntityAccessServiceImpl::new(PgAccessRepository::new(pool.clone())),
);
let images = VisionImageCaptioner::new(
static_file::outbound::CdnStaticFileRepo::new(StaticFileServiceUrl::new()?.to_string()),
@@ -215,7 +221,7 @@ async fn consume<Events: TriggerEvents>(
publisher: &Publisher,
channel_types: &ChannelTypes,
messages: &dyn MessageServiceApi,
- task_context: &DssTaskAssignmentContext,
+ task_context: &impl TaskAssignmentContext,
project_assignments: &ProjectAssignmentService<
impl PropertiesService,
impl InitiativeRepo,
diff --git a/services/agent_trigger_service/src/main.rs b/services/agent_trigger_service/src/main.rs
index 0e32f0ab70..783347d051 100644
--- a/services/agent_trigger_service/src/main.rs
+++ b/services/agent_trigger_service/src/main.rs
@@ -11,7 +11,9 @@ use agent_trigger::domain::processing::process_message_event;
use agent_trigger::domain::project_assignment::ProjectAssignmentService;
use agent_trigger::domain::service::AgentTriggerService;
use agent_trigger::domain::sources::{MessageTriggerEvents, TriggerEvents};
-use agent_trigger::domain::task_assignment::process_task_assignment;
+use agent_trigger::domain::task_assignment::{
+ ProjectTaskAssignmentContext, TaskAssignmentContext, process_task_assignment,
+};
use agent_trigger::outbound::{
BotRepoAgentLookup, ChannelRepoTypeLookup, DssTaskAssignmentContext, FastModelTriggerJudge,
LexicalExplicitReplyExtractor, MessageThreadHistory, VisionImageCaptioner,
@@ -138,12 +140,16 @@ async fn run() -> anyhow::Result<()> {
pool.clone(),
config.enable_ai_usage_enforcement,
);
- let task_context = DssTaskAssignmentContext::new(
- DocumentStorageServiceClient::new(
- config.document_storage_service_auth_key.clone(),
- DocumentStorageServiceUrl::new()?.to_string(),
+ let task_context = ProjectTaskAssignmentContext::new(
+ DssTaskAssignmentContext::new(
+ DocumentStorageServiceClient::new(
+ config.document_storage_service_auth_key.clone(),
+ DocumentStorageServiceUrl::new()?.to_string(),
+ ),
+ lexical.clone(),
),
- lexical.clone(),
+ PgInitiativeRepo::new(pool.clone()),
+ EntityAccessServiceImpl::new(PgAccessRepository::new(pool.clone())),
);
let images = VisionImageCaptioner::new(
static_file::outbound::CdnStaticFileRepo::new(StaticFileServiceUrl::new()?.to_string()),
@@ -240,7 +246,7 @@ async fn consume<Events: TriggerEvents>(
publisher: &Publisher,
channel_types: &ChannelTypes,
messages: &dyn MessageCommands,
- task_context: &DssTaskAssignmentContext,
+ task_context: &impl TaskAssignmentContext,
project_assignments: &ProjectAssignmentService<
impl PropertiesService,
impl InitiativeRepo,