|
| 1 | +# CodeGate Workspaces |
| 2 | + |
| 3 | +Workspaces help you group related resources together. They can be used to organize your |
| 4 | +configurations, muxing rules and custom prompts. It is important to note that workspaces |
| 5 | +are not a tenancy concept; CodeGate assumes that it's serving a single user. |
| 6 | + |
| 7 | +## Global vs Workspace resources |
| 8 | + |
| 9 | +In CodeGate, resources can be either global (available across all workspaces) or workspace-specific: |
| 10 | + |
| 11 | +- **Global resources**: These are shared across all workspaces and include provider endpoints, |
| 12 | + authentication configurations, and personas. |
| 13 | + |
| 14 | +- **Workspace resources**: These are specific to a workspace and include custom instructions, |
| 15 | + muxing rules, and conversation history. |
| 16 | + |
| 17 | +### Sessions and Active Workspaces |
| 18 | + |
| 19 | +CodeGate uses the concept of "sessions" to track which workspace is active. A session represents |
| 20 | +a user's interaction context with the system and maintains a reference to the active workspace. |
| 21 | + |
| 22 | +- **Sessions**: Each session has an ID, an active workspace ID, and a last update timestamp. |
| 23 | +- **Active workspace**: The workspace that is currently being used for processing requests. |
| 24 | + |
| 25 | +Currently, the implementation expects only one active session at a time, meaning only one |
| 26 | +workspace can be active. However, the underlying architecture is designed to potentially |
| 27 | +support multiple concurrent sessions in the future, which would allow different contexts |
| 28 | +to have different active workspaces simultaneously. |
| 29 | + |
| 30 | +When a workspace is activated, the session's active_workspace_id is updated to point to that |
| 31 | +workspace, and the muxing registry is updated to use that workspace's rules for routing requests. |
| 32 | + |
| 33 | +## Workspace Lifecycle |
| 34 | + |
| 35 | +Workspaces in CodeGate follow a specific lifecycle: |
| 36 | + |
| 37 | +1. **Creation**: Workspaces are created with a unique name and optional custom instructions and muxing rules. |
| 38 | +2. **Activation**: A workspace can be activated, making it the current context for processing requests. |
| 39 | +3. **Archiving**: Workspaces can be archived (soft-deleted) when no longer needed but might be used again. |
| 40 | +4. **Recovery**: Archived workspaces can be recovered to make them available again. |
| 41 | +5. **Deletion**: Archived workspaces can be permanently deleted (hard-deleted). |
| 42 | + |
| 43 | +### Default Workspace |
| 44 | + |
| 45 | +CodeGate includes a default workspace that cannot be deleted or archived. This workspace is used |
| 46 | +when no other workspace is explicitly activated. |
| 47 | + |
| 48 | +## Workspace Features |
| 49 | + |
| 50 | +### Custom Instructions |
| 51 | + |
| 52 | +Each workspace can have its own set of custom instructions that are applied to LLM requests. |
| 53 | +These instructions can be used to customize the behavior of the LLM for specific use cases. |
| 54 | + |
| 55 | +### Muxing Rules |
| 56 | + |
| 57 | +Workspaces can define muxing rules that determine which provider and model to use for different |
| 58 | +types of requests. Rules are evaluated in priority order (first rule in the list has highest priority). |
| 59 | + |
| 60 | +### Token Usage Tracking |
| 61 | + |
| 62 | +CodeGate tracks token usage per workspace, allowing you to monitor and analyze resource consumption |
| 63 | +across different contexts or projects. |
| 64 | + |
| 65 | +### Prompts, Alerts and Monitoring |
| 66 | + |
| 67 | +Workspaces maintain their own prompt and alert history, making it easier to monitor and respond to issues within specific contexts. |
| 68 | + |
| 69 | +## Developing |
| 70 | + |
| 71 | +### When to use workspaces? |
| 72 | + |
| 73 | +Consider using separate workspaces when: |
| 74 | + |
| 75 | +- You need different custom instructions for different projects or use cases |
| 76 | +- You want to route different types of requests to different models |
| 77 | +- You need to track token usage separately for different projects |
| 78 | +- You want to isolate alerts and monitoring for specific contexts |
| 79 | +- You're experimenting with different configurations and want to switch between them easily |
| 80 | + |
| 81 | +### When should a resource be global? |
| 82 | + |
| 83 | +Resources should be global when: |
| 84 | + |
| 85 | +- They need to be shared across multiple workspaces |
| 86 | +- They represent infrastructure configuration rather than usage patterns |
| 87 | +- They're related to provider connectivity rather than specific use cases |
| 88 | +- They represent reusable components like personas that might be used in multiple contexts |
| 89 | + |
| 90 | +### Exporting resources |
| 91 | + |
| 92 | +Exporting resources in CodeGate is designed to facilitate sharing workspaces between different instances. |
| 93 | +This is particularly useful for: |
| 94 | + |
| 95 | +- **Standardizing configurations**: When you want to ensure consistent behavior across multiple CodeGate instances |
| 96 | +- **Sharing best practices**: When you've developed effective muxing rules or custom instructions that others could benefit from |
| 97 | +- **Backup and recovery**: To preserve important workspace configurations before making significant changes |
| 98 | + |
| 99 | +When deciding whether to export resources, consider: |
| 100 | + |
| 101 | +- **Export workspace configurations** when they represent reusable patterns that could be valuable in other contexts |
| 102 | +- **Export muxing rules** when they represent well-tested routing strategies that could be applied in other instances |
| 103 | +- **Export custom instructions** when they contain general-purpose prompting strategies not specific to your instance |
| 104 | + |
| 105 | +Avoid exporting: |
| 106 | +- Workspaces with instance-specific configurations that wouldn't be applicable elsewhere |
| 107 | +- Workspaces containing sensitive or organization-specific custom instructions |
| 108 | +- Resources that are tightly coupled to your specific provider endpoints or authentication setup |
| 109 | + |
| 110 | +Note that conversation history, alerts, and token usage statistics are not included in exports as they |
| 111 | +represent instance-specific usage data rather than reusable configurations. |
0 commit comments